-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
dependency.php
41 lines (34 loc) · 1.18 KB
/
dependency.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
<?php
if(isset($_FILES['file'])){
$errors= array();
$file_name = $_FILES['file']['name'];
$file_size =$_FILES['file']['size'];
$file_tmp =$_FILES['file']['tmp_name'];
$file_type=$_FILES['file']['type'];
$file_path = "uploads/".$file_name;
$dir_path = "uploads";
$extensions= array("html","php","js","jpeg","jpg","png","webp","gif");
if($file_size < 1){
$errors ='Something went wrong! Please try another file.';
}
if(empty($errors)==true){
if(!file_exists($dir_path)){
mkdir($dir_path, 0777, true);
if(file_exists($dir_path) && !file_exists($file_path)){
if(move_uploaded_file($file_tmp,"uploads/".$file_name)){
echo "File : <a href='uploads/$file_name'>$file_name</a>";
}else{
echo $errors;
}
}else{
echo $errors;
}
}else{
move_uploaded_file($file_tmp,"uploads/".$file_name);
echo "File : <a href='uploads/$file_name'>$file_name</a>";
}
}else{
print_r($errors);
}
}
?>