Commit 4696afd6 authored by Paarth's avatar Paarth

minor

parent bf95b9eb
......@@ -18,7 +18,6 @@ if (isset($postData) && !empty($postData)) {
mysqli_query($mysqli,$sql);
$msg = "file successfully deleted";
echo json_encode($msg);
}
else{
http_response_code(404);
......
......@@ -11,34 +11,45 @@ if (isset($postData) && !empty($postData)) {
$lang = trim($request->language);
$path = '../users/' . $username . '/' . trim($request->path) . '/' . $filename . $lang;
// if (file_exists($path)) {
// $msg = "file already exists";
// clearstatcache();
// echo json_encode($msg);
// }
// else {
// $sql1 = "SELECT n_files from userdata where username = $username";
// $sql2 = "UPDATE userdata SET n_files = n_files+1 WHERE username = $username ";
// $result = mysqli_query($mysqli, $sql1);
// if($result == 10){
// $msg = "maximum limit(10) reached";
// echo json_encode($msg);
// }
// else{
// if($result = mysqli_query($mysqli, $sql2)) {
$myfile = fopen($path, "w");
fwrite($myfile, $data);
fclose($myfile);
$msg = "file successfully uploaded";
clearstatcache();
echo json_encode($msg);
// }
// else{
// http_response_code(404);
// }
// }
// }
if (file_exists($path)) {
$msg = "file already exists";
clearstatcache();
echo json_encode($msg);
}
else {
$sql1 = "SELECT n_files from user where username = $username";
$sql2 = "UPDATE user SET n_files = n_files+1 WHERE username = $username ";
$result = mysqli_query($mysqli, $sql1)->fetch_all()[0];
if(file_exists($path)){
$myfile = fopen($path, "w");
fwrite($myfile, $data);
fclose($myfile);
$msg = "file successfully uploaded";
clearstatcache();
echo json_encode($msg);
exit;
}
if($result == 10){
$msg = "maximum limit(10) reached";
echo json_encode($msg);
}
else{
if(mysqli_query($mysqli, $sql2)){
$myfile = fopen($path, "w");
fwrite($myfile, $data);
fclose($myfile);
$msg = "file successfully uploaded";
clearstatcache();
echo json_encode($msg);
}
else{
http_response_code(404);
}
}
}
}
......
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