-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathnote.php
More file actions
66 lines (63 loc) · 1.99 KB
/
Copy pathnote.php
File metadata and controls
66 lines (63 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
include 'connect.php';
include 'header.php';
if(isset($_FILES['files'])){
$errors= array();
foreach($_FILES['files']['tmp_name'] as $key => $tmp_name ){
$file_name = $key.$_FILES['files']['name'][$key];
$file_size =$_FILES['files']['size'][$key];
$file_tmp =$_FILES['files']['tmp_name'][$key];
$file_type=$_FILES['files']['type'][$key];
if($file_size > 2097152){
$errors[]='File size must be less than 2 MB';
}
$query="insert into chapter (`FILE_NAME`,`FILE_SIZE`,`FILE_TYPE`) VALUES($file_name','$file_size','$file_type'); ";
$desired_dir="upload";
if(empty($errors)==true){
if(is_dir($desired_dir)==false){
mkdir("$desired_dir", 0700); // Create directory if it does not exist
}
if(is_dir("$desired_dir/".$file_name)==false){
move_uploaded_file($file_tmp,"$desired_dir/".$file_name);
}else{ // rename the file if another one exist
$new_dir="$desired_dir/".$file_name.time();
rename($file_tmp,$new_dir) ;
}
mysqli_query($conn,$query);
}else{
print_r($errors);
}
}
if(empty($error)){
echo "Success";
}
}
?>
<div class="video-menu" style="height: 70px;">
<ul>
<a href="teacher_dashboard.php"><li> Classes
</li></a>
<a href="my_upload.php"><li>
My Uploads
</li></a>
<a href="my-notes.php"><li style="background: #555";>
Add Notes
</li></a>
<a href="add_topic.php"><li>
Add Topic
</li></a></ul>
</div>
<div class="login-form">
<form action="" method="POST" enctype="multipart/form-data">
Click Here to Upload PDF-->
<input type="file" name="files[]" multiple/>
<input type="submit"/><br>
Click Here to Upload DOCUMENT-->
<input type="file" name="files[]" multiple/>
<input type="submit"/><br>
Click Here to Upload TextFile-->
<input type="file" name="files[]" multiple/>
<input type="submit"/>
</form>
</div>
</form>