-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupload.php
More file actions
55 lines (46 loc) · 1.66 KB
/
upload.php
File metadata and controls
55 lines (46 loc) · 1.66 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
<?php
if( $_POST )
//&& isset($_FILES['file'])
{
session_start();
$connect = mysql_connect("localhost", "root", "");
if (!$connect)
{
die("Could not connect to DB at this time, error:" . mysql_error());
echo 'DB Issues';
}
mysql_select_db("alicinamemar", $connect);
$title = $_POST['title'];
$authors = $_POST['authors'];
$affiliation = $_POST['affiliation'];
$email = $_POST['email'];
$title = mysql_real_escape_string($title);
$authors = mysql_real_escape_string($authors);
$affiliation = mysql_real_escape_string($affiliation);
$email = mysql_real_escape_string($email);
$title = stripslashes($title);
$email = stripslashes($email);
$authors = stripslashes($authors);
$affiliation = stripslashes($affiliation);
$username = $_SESSION['username'];
$file = $username . "_" . rand(100,1000000) . $_FILES['file']['name'];
$location= $_FILES['file']['tmp_name'];
$size = $_FILES['file']['size'];
$type = $_FILES['file']['type'];
$folder="uploads/";
if (move_uploaded_file($location, $folder.$file))
{
$insertion = "INSERT INTO `alicinamemar`.`upload` (`id`, `title`, `authors`, `affiliation`, `email`, `upload`, `type`, `timestamp`, `size`, `username`) VALUES (NULL, '$title', '$authors', '$affiliation', '$email', '$file', '$type', CURRENT_TIMESTAMP, '$size', '$username' )";
mysql_query($insertion);
mysql_close($connect);
header("Location: submission.php");
}
else
{
echo
<script>alert('Upload Error');
window.location.href='submission.php?fail';</script>
";
}
}
?>