multiple uploading files

#1
[eluser]rakish[/eluser]
Hi..any idea about multiple uploading files? I'm having a hard time for this..

answers will be highly appreciate, thank you soo much! in advance..Smile

#2
[eluser]saidai jagan[/eluser]
yes...
Do the process in the forloop.

#3
[eluser]rakish[/eluser]
Here is my code and there's still a problem..I need help?


function do_upload()
{
$files = array('userfile_0'=>array('upload_path'=>'./media/uploads/','allowed_types'=>'gif|jpg|png','max_size'=>100),
'userfile_1'=>array('upload_path'=>'./media/uploads/about','allowed_types'=>'gif|jpg|png','max_size'=>100));

$this->load->library('upload');

$res['id'] = 1;
$res['missionimage'] = $_FILES['userfile_0']['name'];
$res['staffimage'] = $_FILES['userfile_1']['name'];


foreach($files as $field=>$settings)
{

$this->upload->initialize($settings);


if ( !$this->upload->do_upload($field))
{

redirect('backend/about/index/tryagain');
}
else
{
$data = array('upload_data' => $this->upload->data());
$this->mabout_content->uploadPhoto($res);

redirect('backend/about/index/imagesaved');
}
}
}

#4
[eluser]CI_avatar[/eluser]
please check this ajaxupload it works for me.
i am using it in my codeigniter.

http://valums.com/ajax-upload/

note: ajaxupload requires jquery

#5
[eluser]Zeeshan Rasool[/eluser]
[quote author="rakish" date="1258458726"]Hi..any idea about multiple uploading files? I'm having a hard time for this..

answers will be highly appreciate, thank you soo much! in advance..Smile[/quote]

Either you can do it with repeating your one piece of code for all files to upload or use a loop to upload all files.

#6
[eluser]Unknown[/eluser]
I'm not sure how good you are with Flash AS3, but it has a FileReferenceList class that allows you to select multiple files and then upload them in a queue to a controller method for processing.

I use this all the time and it works really well, especially when you need to filter file types or check the size of something before you post it to the server. Because its routed through Flash, you also get upload progress data and can display the percent uploaded or create a progress bar.

#7
[eluser]Unknown[/eluser]
I made this function, all you need to do is run it, and make some small changes in CI files.
Code:
/*
** @param config - (array) config data for CI upload class
** @$field_name - (str) field where you have files to upload
*/
public function processMultipeUpload($config, $field_name) {
    $store = $_FILES;
    unset($_FILES);
    $this->load->library('upload', $config);
    
    // you may need to set $x = 0; I dont use first file field, form sends it with "" values
    for($x = 1; $x < count($store["img"]["name"]); $x++) {
        $_FILES["userfile"]["name"]        = $store[$field_name]["name"][$x];
        $_FILES["userfile"]["type"]        = $store[$field_name]["type"][$x];
        $_FILES["userfile"]["tmp_name"]    = $store[$field_name]["tmp_name"][$x];
        $_FILES["userfile"]["error"]       = $store[$field_name]["error"][$x];
        $_FILES["userfile"]["size"]        = $store[$field_name]["size"][$x];
    
    
        if( ! $this->upload->do_upload() ) {
            // fail
        }else{
            // success
        }
    }
}
You also need to edit CI Upload library. To line 291 (end of do_upload function) add:
Code:
$this->file_name    = "";
and in function _prep_filename move:
Code:
$filename .= '.'.$ext;
before:
Code:
if ($this->file_name != '')
{
    $filename = $this->file_name;
}
If you won't do this, CI will generate bad names: first_file.ext, second_file.ext.ext, third_file.ext.ext.ext and so. If you won't clear filename names will be like: first_file.ext, first_file1.ext (but if will be 2nd file), third_file11.ext (3rd file..) and so.

Hope it'll help, and sorry for my English, not used to speak much.

#8
[eluser]alvk4r[/eluser]
May be the solution it's http://ellislab.com/forums/viewthread/156352/


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.