Commit 93b64d57 authored by Ayush's avatar Ayush

Minor fix

parent bf95b9eb
......@@ -11,35 +11,24 @@ 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);
// }
// }
// }
$sql1 = "SELECT n_files from users where username = '$username'";
$sql2 = "UPDATE users SET n_files = n_files+1 WHERE username = '$username'";
$result = mysqli_query($mysqli, $sql1)->fetch_all()[0];
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);
}
}
}
?>
......@@ -39,7 +39,7 @@ export class HomeComponent implements OnInit {
this.getProblems();
// this.questionService.getQues()
// .subscribe(questions => this.questions = questions);
// console.log(this.questions);
}
......@@ -49,11 +49,11 @@ export class HomeComponent implements OnInit {
}
openForm(): void {
document.getElementById("popupForm").style.display = "block";
document.getElementById('popupForm').style.display = 'block';
}
closeForm(): void {
document.getElementById("popupForm").style.display = "none";
document.getElementById('popupForm').style.display = 'none';
}
resetForm(): void {
......@@ -71,15 +71,18 @@ export class HomeComponent implements OnInit {
}
submitForm() {
this.questiontoPost.start_time = this.questiontoPost.start_time.split('T').join(' ');
this.questiontoPost.end_time = this.questiontoPost.end_time.split('T').join(' ');
this.questionService.uploadQues(this.questiontoPost).subscribe(
(event: any) => {
if (typeof (event) === 'object') {
this.questiontoPost = null;
(document.getElementById('quesform') as HTMLInputElement).value = '';
}
this.resetForm();
this.closeForm();
}
);
this.resetForm();
this.closeForm();
}
}
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