CodeIgniter Forums
Multiple upload function - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22)
+--- Thread: Multiple upload function (/showthread.php?tid=6215)

Pages: 1 2 3 4


Multiple upload function - El Forum - 10-05-2009

[eluser]Référencement Google[/eluser]
As the method returns the $files array it is easy to get back the file name from it (just print_r the returned value to see what exactly).


Multiple upload function - El Forum - 10-05-2009

[eluser]artlover[/eluser]
aha!

$files[0]["file_name"]
$files[1]["file_name"]

are giving the renamed file names!! thanks for clue @Too Pixel Smile


Multiple upload function - El Forum - 10-05-2009

[eluser]Référencement Google[/eluser]
You welcome.


Multiple upload function - El Forum - 11-10-2009

[eluser]luffy[/eluser]
Is it better if I put the function in the model?


Multiple upload function - El Forum - 11-10-2009

[eluser]Zack Kitzmiller[/eluser]
[quote author="luffy" date="1257879826"]Is it better if I put the function in the model?[/quote]

I would. I always keep file uploads in a file model.


Multiple upload function - El Forum - 11-10-2009

[eluser]Référencement Google[/eluser]
I personaly extends the CI_Upload lib in a MY_Upload lib which I think is the most appropriate place to put upload code.

More generally I tend to extend CI first before thinking of putting my code in a model or a helper, eg. if I have to do something about images, I will extend the Image lib.


Multiple upload function - El Forum - 11-11-2009

[eluser]luffy[/eluser]
Most of the time, I use single upload.

I will use multiple upload in a few times.

So I put the function in the model.


Multiple upload function - El Forum - 02-02-2010

[eluser]alrightythen[/eluser]
is this code still correct? because I keep getting the 'The upload path does not appear to be valid' error


Multiple upload function - El Forum - 02-02-2010

[eluser]Référencement Google[/eluser]
The code should still be correct. It is more likely that you must check your upload path, maybe not using the realpath as I did.


Multiple upload function - El Forum - 02-02-2010

[eluser]alrightythen[/eluser]
[quote author="Too Pixel" date="1265158329"]The code should still be correct. It is more likely that you must check your upload path, maybe not using the realpath as I did.[/quote]

Oh hi, a reply from the master himself.
Yes I've tried realpath($upload_dir) and base_url().$upload_dir but neither one of them work

With this code..
Code:
foreach($_FILES as $key => $value)
            {    
                if( ! empty($value['name']))
                {
                    if( ! $CI->upload->do_upload($key))
                    {                                      

                /*    there's something wrong going on here!     */
    
                        $data['upload_message'] = $CI->upload->display_errors();
                        
                        echo 'echo upload_message';
                        echo $data['upload_message'];
                        echo '<br/><br/>';
                        
                        echo 'echo upload_path<br/>';
                        echo $config['upload_path'];
                        echo '<br/><br/>';
                        
                        $errors = TRUE;
                    }
                    else
                    {
                        // Build a file array from all uploaded files
                        $files[] = $CI->upload->data();
                    }
                }
            }

I get..
echo upload_message
The upload path does not appear to be valid.

echo upload_path
/Applications/MAMP/htdocs/costa/uploads

while the $upload_dir = 'uploads'


I'm calling the function like this..
Code:
$this->load->library('upload');
        if(!$files = $this->upload->multiple_upload())
        {
            echo 'Something went wrong during upload';
        }
        else
        {
            echo 'Upload success !<br />';
            echo '<pre>';
            print_r($files);
            echo '</pre>';
        }