-
Notifications
You must be signed in to change notification settings - Fork 0
/
upload.php
executable file
·40 lines (33 loc) · 989 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
31
32
33
34
35
36
37
38
39
40
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
if($_SERVER["REQUEST_METHOD"] == "POST"){
$file = $_FILES['file'];
$filetmpName = $_FILES['file']['tmp_name'];
$fileSize = $_FILES['file']['size'];
$fileterror= $_FILES['file']['error'];
$fileType = $_FILES['file']['type'];
$fileExt = explode('/' , $fileType );
$fileActualExt = strtolower( end($fileExt) );
$allowed = array('jpg', 'jpeg', 'png');
echo $fileActualExt;
if( in_array($fileActualExt, $allowed) ){
if($fileterror === 0){
if($fileSize < 1000000){
$filenameNew = uniqid('', true) . "." . $fileActualExt;
$filedestination = '/uploads' . $filenameNew;
move_uploaded_file($filetmpName , $filedestination);
echo "your file has been uploaded";
}else{
echo "your file is too big";
}
}else{
echo "there has been an error uploading yout file";
}
}else{
echo "you can not ipload files of this type";
}
}
else{
echo "no submit found ";
}