Welcome Guest, Not a member yet? Register   Sign In
upload multiple files
#11

[eluser]jacobc[/eluser]
[quote author="TheFuzzy0ne" date="1236849012"]It simply checks for a file upload name "userfile" to make it more convenient to upload a single file. You are free to specify you're own file input name if you want. Also, there really is no need to change the $_FILES array in any way. In fact, there should be no need to even have to access it. The upload class takes care of it all, you just need to provide it with the necessary configuration array.[/quote]

But if a user has input names for the file inputs like
File 1: <input type="file" name="userfile[]">
File 2: <input type="file" name="userfile[]">

Line 154 of Upload.php has
Code:
! is_uploaded_file($_FILES[$field]['tmp_name'])

But the $_FILES variable in this case would be
$_FILES[$field]['tmp_name'][0]
$_FILES[$field]['tmp_name'][1]

Hence the need to change $_FILES to use the Upload class as is.
#12

[eluser]jacobc[/eluser]
By the way I do agree you shouldn't change the $_FILES variable... Which is even more so why I think the Upload library should handle multiple files with the same fieldname.
#13

[eluser]TheFuzzy0ne[/eluser]
You're right. I guess I was getting it confused with the form validation class, and the way it handles arrays. My sincere apologies. I think it's bed time. It's 04:36AM.
#14

[eluser]e-mike[/eluser]
Please see Single, Multiple and Multiple array upload library for a solution (hopefully soon)...
#15

[eluser]bluepicaso[/eluser]
I'm using this.
I'm trying to upload a pdf and a image.
They get uploaded. BUt instead of the different name. The PDF file has a nave like
image.jpg.pdf
Where the image is saved as image.jpg.



Code:
$config['upload_path'] = "images/gems";
        $config['allowed_types'] = "pdf|gif|jpg|jpeg|png";
        $config['max_size'] = "5000";
        $config['maintain_ratio'] = TRUE;
        $config['max_width'] = "3000";
        $config['max_height'] = "3000";
        $this->load->library('upload', $config);
          
            for($i=0;$i<count($_FILES['userfile']['name']);$i++)
            {
                echo $_FILES['userfile']['name'][$i];
            $files[$i]['name'] = $_FILES['userfile']['name'][$i];
            $files[$i]['type'] = $_FILES['userfile']['type'][$i];
            $files[$i]['tmp_name'] = $_FILES['userfile']['tmp_name'][$i];
            $files[$i]['error'] = $_FILES['userfile']['error'][$i];
            $files[$i]['size'] = $_FILES['userfile']['size'][$i];
        }
          
            $_FILES = array();
            $_FILES = $files;
        
            print_r($files);


            $this->load->library('upload', $config);
            for($i=0;$i<count($_FILES);$i++)
            {
            if ( ! $this->upload->do_upload($i))
            {
                echo $this->upload->display_errors();
            }
            else
            {
                echo "DONE";
            }
            }
Also i want to know how can i create thumbnail for the image.
#16

[eluser]bluepicaso[/eluser]
Also there is a problem. The Thumbnail created with the same image name creates the thumbnail with the same name. Hence it overrides the previous thumbnail....
Please help




Theme © iAndrew 2016 - Forum software by © MyBB