コード例 #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);
 }