-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathrespond.php
More file actions
executable file
·44 lines (39 loc) · 962 Bytes
/
respond.php
File metadata and controls
executable file
·44 lines (39 loc) · 962 Bytes
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
44
<?php
// error_reporting(E_ALL);
// ini_set('display_errors', 1);
function uploadFile ($file) {
if ($file["error"]) {
return array('error' => $file['error']);
}
else {
move_uploaded_file(
$file["tmp_name"],
"uploads/" . $file["name"]
);
return array(
'name' => $file['name'],
'type' => $file['type'],
'size' => $file['size'],
'tmp_name' => $file['tmp_name']
);
}
}
$fileResults = array();
foreach($_FILES ?: array() as $file) {
$fileResults[] = uploadFile($file);
}
if(isset($_POST['text']) && $_POST['text'] === 'w') {
echo json_encode(array(
'status' => 409,
'text' => 'server doesnt like w',
'GLOBAL' => 'server error occurred'
));
}
else {
echo json_encode(array(
'successMessage' => 'Success!',
'requestData' => $_POST,
'fileData' => $fileResults
));
}
?>