-
Notifications
You must be signed in to change notification settings - Fork 16
/
upload.php
42 lines (37 loc) · 1.27 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
<link type="text/css" rel="stylesheet" href="stylesheet.css">
<?php
include 'config.php';
session_start();
// Check if the user is logged in, otherwise redirect to login page
if(!isset($_SESSION["loggedin"]) || $_SESSION["loggedin"] !== true){
header("location: student_login.php");
exit;
}
#retrieve file title
$title = $_POST["title"];
$id = $_POST["id"];
$pac = $_POST["pac"];
$regdno=$_SESSION["num"];
#file name with a random number so that similar dont get replaced
$pname = rand(1000,10000)."-".$_FILES["file"]["name"];
#temporary file name to store file
$tname = $_FILES["file"]["tmp_name"];
//$pname="uploaded_files/".$pname;
#upload directory path
#TO move the uploaded file to specific location
move_uploaded_file($tname, "uploaded_files/".$pname);
#sql query to insert into database
$sql = "INSERT into package(regdno,id,companyname,package,file) VALUES('$regdno','$id','$title','$pac','$pname')";
if(mysqli_query($conn,$sql)){
echo "File Sucessfully uploaded";
echo "<br>";
echo "<br>";
echo "<br>";
?>
<a href="update_placement.php" class="button">Back</a>
<?php
}
else{
echo "Error";
}
?>