-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupload.php
29 lines (24 loc) · 1.02 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
<?php
if (!empty($_FILES) && isset($_FILES['fileToUpload'])) {
switch ($_FILES['fileToUpload']["error"]) {
case UPLOAD_ERR_OK:
$target = "upload/";
$target = $target . basename($_FILES['fileToUpload']['name']);
if (move_uploaded_file($_FILES['fileToUpload']['tmp_name'], $target)) {
$status = "The file " . basename($_FILES['fileToUpload']['name']) . " has been uploaded";
$imageFileType = pathinfo($target, PATHINFO_EXTENSION);
$check = getimagesize($target);
if ($check !== false) {
echo "File is an image - " . $check["mime"] . ".<br>";
$uploadOk = 1;
} else {
echo "File is not an image.<br>";
$uploadOk = 0;
}
} else {
$status = "Sorry, there was a problem uploading your file.";
}
break;
}
echo "Status: {$status}<br/>\n";
}