示例#1
0
文件: api.php 项目: osuisumi/OS.js
 /**
  * File Upload Requests
  */
 public static function FilePOST(APIRequest $req)
 {
     $result = false;
     $error = false;
     // FIXME: Frontend does not show error
     call_user_func_array(array(API::$Handler, 'checkPrivilege'), array(APIUser::GROUP_UPLOAD));
     try {
         if (isset($_POST['path']) && isset($_FILES['upload'])) {
             if (FS::upload($_POST['path'], $_FILES['upload'])) {
                 $result = true;
             } else {
                 $error = "File was not uploaded";
             }
         }
     } catch (Exception $e) {
         $error = "File upload failed: {$e->getMessage()}";
     }
     return new APIResponse(false, $result, $error);
 }