Commit 327846c1 authored by Paarth's avatar Paarth

updated filedelete.php for directory

parent 6fea0680
......@@ -4,16 +4,31 @@ include_once("database.php");
$postData = file_get_contents("php://input");
if (isset($postData) && !empty($postData)) {
$request = json_decode($postData);
$isFile = trim($request->isFile);
if(isFile){
$username = trim($request['file']['username']);
$filename = trim($request['file']['filename']);
$lang = trim($request['file']['language']);
$path = '../users/' . $username . '/' . trim($request->path) . '/' . $filename . $lang;
if (unlink($path)) {
$msg = "file successfully deleted";
echo json_encode($msg);
}
else{
http_response_code(404);
}
exit;
}
$username = trim($request->username);
$data = trim($request->text);
$filename = trim($request->filename);
$lang = trim($request->language);
$path = '../users/' . $username . '/' . trim($request->path) . '/' . $filename . $lang;
$dirname = trim($request['file']['name']);
$path = '../users/' . $username . '/' . trim($request['file']['path']) . '/' . $dirname;
if (unlink($path)) {
$msg = "file successfully deleted";
clearstatcache();
if (rmdir($path)) {
$msg = "directory successfully deleted";
echo json_encode($msg);
}
else {
......
......@@ -6,7 +6,7 @@ header("Access-Control-Allow-Methods: PUT, GET, POST, DELETE");
header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept");
header("Content-Type: application/json; charset=UTF-8");
include_once("database.php");
include_once("../database.php");
$postData = file_get_contents("php://input");
if(isset($postData) && !empty($postData)){
......
......@@ -19,7 +19,6 @@ if (isset($postData) && !empty($postData)) {
'id' => mysqli_insert_id($mysqli),
'username' => $username
];
mkdir('../users/' . $authData['username'], 0755, true);
$mysqli->query($sql1);
echo json_encode($authData);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment