-
Notifications
You must be signed in to change notification settings - Fork 0
/
upload.php
30 lines (30 loc) · 879 Bytes
/
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
<?php
session_start();
if($_FILES['file']['name'] != '')
{
$name=$_FILES['file']['name'];
$name=explode(".", $name);
$extension = end($name);
echo "<script>alert(".$extension.");</script>";
$allowed_type = array("jpg");
if(in_array($extension, $allowed_type))
{
$new_name = $_SESSION['regno'].".". $extension;
$path = "img/std_img/". $new_name;
if(move_uploaded_file($_FILES['file']['tmp_name'], $path))
{
echo "<script>
alert(\"Image Uploaded Sucessfully\");
</script>";
}
}
else
{
echo '<script>alert("Invalid File Format,Use \'.jpg\' extension only")</script>';
}
}
else
{
echo '<script>alert("Please Select File")</script>';
}
?>