Example #1
0
 /**
  * Loads uploaded file from table change request.
  *
  * @param string $key       the md5 hash of the column name
  * @param string $rownumber number of row to process
  *
  * @return boolean success
  * @access  public
  */
 public function setUploadedFromTblChangeRequest($key, $rownumber)
 {
     if (!isset($_FILES['fields_upload']) || empty($_FILES['fields_upload']['name']['multi_edit'][$rownumber][$key])) {
         return false;
     }
     $file = File::fetchUploadedFromTblChangeRequestMultiple($_FILES['fields_upload'], $rownumber, $key);
     // check for file upload errors
     switch ($file['error']) {
         // we do not use the PHP constants here cause not all constants
         // are defined in all versions of PHP - but the correct constants names
         // are given as comment
         case 0:
             //UPLOAD_ERR_OK:
             return $this->setUploadedFile($file['tmp_name']);
         case 4:
             //UPLOAD_ERR_NO_FILE:
             break;
         case 1:
             //UPLOAD_ERR_INI_SIZE:
             $this->_error_message = __('The uploaded file exceeds the upload_max_filesize directive in ' . 'php.ini.');
             break;
         case 2:
             //UPLOAD_ERR_FORM_SIZE:
             $this->_error_message = __('The uploaded file exceeds the MAX_FILE_SIZE directive that was ' . 'specified in the HTML form.');
             break;
         case 3:
             //UPLOAD_ERR_PARTIAL:
             $this->_error_message = __('The uploaded file was only partially uploaded.');
             break;
         case 6:
             //UPLOAD_ERR_NO_TMP_DIR:
             $this->_error_message = __('Missing a temporary folder.');
             break;
         case 7:
             //UPLOAD_ERR_CANT_WRITE:
             $this->_error_message = __('Failed to write file to disk.');
             break;
         case 8:
             //UPLOAD_ERR_EXTENSION:
             $this->_error_message = __('File upload stopped by extension.');
             break;
         default:
             $this->_error_message = __('Unknown error in file upload.');
     }
     // end switch
     return false;
 }