-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsaveFiles.php
More file actions
43 lines (28 loc) · 1.1 KB
/
saveFiles.php
File metadata and controls
43 lines (28 loc) · 1.1 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
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST"){//Check if we're calling the php script with correct method
if (isset($_FILES["files"]["name"])){//Check if there's any actual file
//Name of the file
$fileToBeSaved = $_FILES["files"]["name"];
//Where we will save the files
$uploadLocation = "images_sent/";
//Complete future path of current file
$path = $uploadLocation.$fileToBeSaved;
$response = 0;
if (move_uploaded_file($_FILES["files"]["tmp_name"], $path)){
$gb = glob("images_sent/*");
if ($gb != false){
$countOfFiles = count($gb);
$newName = $uploadLocation."imageSent_".$countOfFiles;
rename($path, $newName);
echo $newName;
}
}else{
echo "Failed to upload file";
}
}else{
echo "There is no file to be uploaded";
}
}else{
echo "Invalid Request Method";
}
?>