PMA\libraries\File::fetchUploadedFromTblChangeRequestMultiple PHP Method

fetchUploadedFromTblChangeRequestMultiple() public method

$file['name']['multi_edit'][$rownumber][$key] = [value] $file['type']['multi_edit'][$rownumber][$key] = [value] $file['size']['multi_edit'][$rownumber][$key] = [value] $file['tmp_name']['multi_edit'][$rownumber][$key] = [value] $file['error']['multi_edit'][$rownumber][$key] = [value] becomes: $file['name'] = [value] $file['type'] = [value] $file['size'] = [value] $file['tmp_name'] = [value] $file['error'] = [value]
public fetchUploadedFromTblChangeRequestMultiple ( array $file, string $rownumber, string $key ) : array
$file array the array
$rownumber string number of row to process
$key string key to process
return array
    public function fetchUploadedFromTblChangeRequestMultiple($file, $rownumber, $key)
    {
        $new_file = array('name' => $file['name']['multi_edit'][$rownumber][$key], 'type' => $file['type']['multi_edit'][$rownumber][$key], 'size' => $file['size']['multi_edit'][$rownumber][$key], 'tmp_name' => $file['tmp_name']['multi_edit'][$rownumber][$key], 'error' => $file['error']['multi_edit'][$rownumber][$key]);
        return $new_file;
    }

Usage Example

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 = Message::error(__('The uploaded file exceeds the upload_max_filesize directive in ' . 'php.ini.'));
             break;
         case 2:
             //UPLOAD_ERR_FORM_SIZE:
             $this->_error_message = Message::error(__('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 = Message::error(__('The uploaded file was only partially uploaded.'));
             break;
         case 6:
             //UPLOAD_ERR_NO_TMP_DIR:
             $this->_error_message = Message::error(__('Missing a temporary folder.'));
             break;
         case 7:
             //UPLOAD_ERR_CANT_WRITE:
             $this->_error_message = Message::error(__('Failed to write file to disk.'));
             break;
         case 8:
             //UPLOAD_ERR_EXTENSION:
             $this->_error_message = Message::error(__('File upload stopped by extension.'));
             break;
         default:
             $this->_error_message = Message::error(__('Unknown error in file upload.'));
     }
     // end switch
     return false;
 }