/**
* Multile File Upload
*
* @access public
* @param string
* @return mixed
*/
public function do_multi_upload($field){
//Is $_FILES[$field] set? If not, no reason to continue.
if(!isset($_FILES[$field])){ return false; }
//Is this really a multi upload?
if(!is_array($_FILES[$field]["name"])){
//Fallback to do_upload method.
return $this->do_upload($field);
}
//Is the upload path valid?
if(!$this->validate_upload_path()){
//Errors will already be set by validate_upload_path() so just return FALSE
return FALSE;
}
//Every file will have a separate entry in each of the $_FILES associative array elements (name, type, etc).
//Loop through $_FILES[$field]["name"] as representative of total number of files. Use count as key in
//corresponding elements of the $_FILES[$field] elements.
for($i=0; $i<count($_FILES[$field]["name"]); $i++){
//Was the file able to be uploaded? If not, determine the reason why.
if(!is_uploaded_file($_FILES[$field]["tmp_name"][$i])){
//Determine error number.
$error = (!isset($_FILES[$field]["error"][$i])) ? 4 : $_FILES[$field]["error"][$i];
//Set error.
switch($error){
//UPLOAD_ERR_INI_SIZE
case 1:
$this->set_error("upload_file_exceeds_limit");
break;
//UPLOAD_ERR_FORM_SIZE
case 2:
$this->set_error("upload_file_exceeds_form_limit");
break;
//UPLOAD_ERR_PARTIAL
case 3:
$this->set_error("upload_file_partial");
break;
//UPLOAD_ERR_NO_FILE
case 4:
$this->set_error("upload_no_file_selected");
break;
//UPLOAD_ERR_NO_TMP_DIR
case 6:
$this->set_error("upload_no_temp_directory");
break;
//UPLOAD_ERR_CANT_WRITE
case 7:
$this->set_error("upload_unable_to_write_file");
break;
//UPLOAD_ERR_EXTENSION
case 8:
$this->set_error("upload_stopped_by_extension");
break;
default:
$this->set_error("upload_no_file_selected");
break;
}
//Return failed upload.
return FALSE;
}
//Set current file data as class variables.
$this->file_temp = $_FILES[$field]["tmp_name"][$i];
$this->file_size = $_FILES[$field]["size"][$i];
$this->_file_mime_type($_FILES[$field], $i);
$this->file_type = preg_replace("/^(.+?);.*$/", "\\1", $this->file_type);
$this->file_type = strtolower(trim(stripslashes($this->file_type), '"'));
$this->file_name = $this->_prep_filename($_FILES[$field]["name"][$i]);
$this->file_ext = $this->get_extension($this->file_name);
$this->client_name = $this->file_name;