Manage user-provided files.
Inheritance: extends BlueprintGear
Ejemplo n.º 1
0
 /**
  * Upload files
  *
  * @param int $directoryId
  * @param string $cabin
  * @return array
  */
 protected function uploadFiles($directoryId = null, string $cabin = '') : array
 {
     $results = [];
     $newFiles = $this->files->isolateFiles($_FILES['new_files']);
     if (empty($newFiles)) {
         return ['status' => 'ERROR', 'message' => 'No files were uploaded.'];
     }
     foreach ($newFiles as $file) {
         try {
             $results[] = $this->files->processUpload($directoryId, $cabin, $file, $this->attribution);
         } catch (UploadError $ex) {
             $this->log('File upload failed', LogLevel::ERROR, \Airship\throwableToArray($ex));
         }
     }
     return ['status' => 'SUCCESS', 'message' => 'Upload successful'];
 }