-
Notifications
You must be signed in to change notification settings - Fork 0
/
upload.php
43 lines (30 loc) · 1.23 KB
/
upload.php
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
<?php
include('connect.php');
if(isset($_POST['submit']))
{
$maxfilesize = $_POST['maxfilesize'];
$filename = $_FILES['file']['name'];
$filetemplocation = $_FILES['file']['tmp_name'];
$filesize = $_FILES['file']['size'];
$fileerror = $_FILES['file']['error'];
$fileext = $_FILES['file']['type'];
$course = $_POST['course_name'];
if ($fileerror === 0 && $filesize < $maxfilesize){
$uploadname = rand(1,10) . '_' . basename($filename);
$filenewname = uniqid('', true) . "." . $fileext;
$filedestination = 'uploads/' . $uploadname;
move_uploaded_file($filetemplocation, $filedestination);
$query = "INSERT INTO directory (`id`, `files`, `course`, `batch`, `degree`) VALUES (NULL, '$uploadname', '$course', '', '');";
$query1 = $query;
mysqli_query($conn, $query1);
$message = "Your file has been uploaded";
echo "<script type='text/javascript'>alert('$message');</script>";
}
else {
echo("Some Error maybe") ;
}
}
else{
echo "File size too big man" ;
}
?>