-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapi.php
More file actions
31 lines (31 loc) · 898 Bytes
/
Copy pathapi.php
File metadata and controls
31 lines (31 loc) · 898 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
<?php
server();
function server()
{
$data = [];
if (!isset($_GET['action'])) {
return;
}
switch ($_GET['action']) {
case 'upload':
$data = ['data' => []];
$files = $_FILES['files'];
if (!is_array($files) || empty($files)) {
return;
}
foreach ($files['tmp_name'] as $k => $v) {
$path = "/uploads/{$files['name'][$k]}";
move_uploaded_file($v, "." . $path);
$data['data'][] = "http://{$_SERVER['HTTP_HOST']}{$path}";
}
break;
case 'save':
file_put_contents("./data.json", file_get_contents("php://input"));
die('ok');
break;
case 'load':
$data = json_decode(file_get_contents("./data.json"));
break;
}
echo json_encode($data);
}