[eluser]steviez[/eluser]
Hi,
I am trying to make codeigniter upload multiple files at once but all i get is errors. My code is this:
Code:
function do_upload()
{
// set upload set id
$set_id = md5(rand(1, 7) . rand(1, 4) . rand(1, 6));
// check to make sure upload form was posted
if($this->input->post('task') == "doUpload")
{
// create upload directory
if(!@mkdir($this->core->site_config['upload_path'] . $set_id . "/"))
{
// set flash message
$this->session->set_flashdata('upload_error', 'Failed to create upload directory.');
// redirect
redirect($this->core->site_config['site_url'], 301);
}
// if new upload directory exists add index.html file
if(is_dir($this->core->site_config['upload_path'] . $set_id . "/"))
{
$fh = fopen($this->core->site_config['upload_path'] . $set_id . "/index.html", "w");
fclose($fh);
}
// create the config for upload library
$config['upload_path'] = $this->core->site_config['upload_path'] . $set_id . "/";
$config['allowed_types'] = 'gif|jpg|png|bmp|jpeg';
$config['max_size'] = $this->core->site_config['max_file_size']; // in KB
$config['max_width'] = '0';
$config['max_height'] = '0';
// load the upload library
$this->load->library('upload', $config);
// create the config for image library
$configThumb = array();
$configThumb['image_library'] = 'gd2';
$configThumb['source_image'] = '';
$configThumb['create_thumb'] = TRUE;
$configThumb['maintain_ratio'] = TRUE;
$configThumb['width'] = 120;
$configThumb['height'] = 120;
// load the image library
$this->load->library('image_lib');
// loop over uploaded image files
while(list($key, $value) = each($_FILES['image']['name']))
{
// handle the file upload
$upload = $this->upload->do_upload($key);
// file failed to upload - continue
//if($upload === FALSE) continue;
// get the data about the file
$data = $this->upload->data();
$uploadedFiles[$key] = $data;
// if the file is an image - create a thumbnail
if($data['is_image'] == 1)
{
$configThumb['source_image'] = $data['full_path'];
$this->image_lib->initialize($configThumb);
$this->image_lib->resize();
}
echo $this->upload->data();
echo $this->upload->display_errors();
}
}
}
but all i get when upload is complete is:
Quote:Array
You did not select a file to upload.
Array
You did not select a file to upload.
You did not select a file to upload.
Array
You did not select a file to upload.
You did not select a file to upload.
You did not select a file to upload.
Array
You did not select a file to upload.
You did not select a file to upload.
You did not select a file to upload.
You did not select a file to upload.
any ideas?