Ejemplo n.º 1
0
 /**
  * file uploading issue:
  *
  * When processing sub-actions, the file objects are shared across the
  * parent action. sometimes the column name will collide with the parent action column names.  
  * To solve this issue, we have to separate the namespace.
  *
  *   solutions:
  *     1. the file upload object should be action-wide not request-wide
  *     2. save the file upload object in the action, not in the request object.
  *     3. do not access $_FILES or request->files directly.
  *
  *   plan:
  *      1. Moved uploadedFile access methods from ActionRequest to Action itself.
  *
  */
 protected function _findUploadedFile($name, &$requireUploadMove)
 {
     // See if there is any UploadedFile object created in this action.
     $uploadedFile = $this->action->request->uploadedFile($name, 0);
     if ($uploadedFile) {
         return $uploadedFile;
     }
     // Uploaded by static path
     if ($uploadedPath = $this->action->arg($name)) {
         $fileArray = Utils::createFileArrayFromPath($uploadedPath);
         return UploadedFile::createFromArray($fileArray);
     }
     // create an uploaded file object from here
     $fileArray = $this->action->request->file($this->name);
     // if there is an upload file in $_FILES
     if ($fileArray && $fileArray['error'] == 0) {
         $requireUploadMove = true;
         return UploadedFile::createFromArray($fileArray);
     }
     return null;
 }