} } } echo json_encode($response); break; case 'download': $file = $_POST['path']; $data = $server->get($file); header("Content-Type: application/octet-stream"); header("Content-Disposition: attachment; filename=\"" . basename($file) . "\""); //header('Content-type: '.$row['type']); print $data; break; case 'chmod': $file = $_POST['file']; if ($server->chmod($file, intval($_POST['mode'], 8))) { echo '{"success":true}'; } else { echo '{"success":false,"error":"Cannot chmod file"}'; } break; case 'uploadByURL': if (substr($_POST['url'], 0, 7) != 'http://' && substr($_POST['url'], 0, 8) != 'https://') { $response['success'] = false; $response['error'] = 'Invalid URL'; } else { $content = file_get_contents($_POST['url']); $file = basename_safe($_POST['url']); if (!$file) { $response['success'] = false; $response['error'] = 'Missing file name';