Welcome Guest, Not a member yet? Register   Sign In
another "multiple file uploading" thread...
#1

[eluser]Fenix[/eluser]
So I've been looking through a bunch of threads on the topic and I'm wondering if there is a simple way to do it.

I have an image upload form that I would like to have a button to dynamically add more files to. So when a user clicks a button it would add another file input field to the form with JavaScript. I know this will work with text input fields by setting

View:
Code:
<form action="<?=$action?>" method="POST" enctype="multipart/form-data">

    <input type="hidden" name="MAX_FILE_SIZE" value="2097152" />
    <div id="files">
        &lt;input name="image" id="image[]" type="file" /&gt;
        &lt;input name="image" id="image[]" type="file" /&gt;
                // ... more
    </div>
    &lt;input type="submit" value="Upload File" /&gt;
    
&lt;/form&gt;

And then the controller could give an array like:
Code:
Array
(
    [0] => array(
            [file_name]    => mypic.jpg
            [file_type]    => image/jpeg
            [file_path]    => /path/to/your/upload/
            [full_path]    => /path/to/your/upload/jpg.jpg
            [raw_name]     => mypic
            [orig_name]    => mypic.jpg
            [file_ext]     => .jpg
            [file_size]    => 22.2
            [is_image]     => 1
            [image_width]  => 800
            [image_height] => 600
            [image_type]   => jpeg
            [image_size_str] => width="800" height="200"
    )
    [1] => array(
            [file_name]    => mypic2.jpg
            [file_type]    => image/jpeg
            [file_path]    => /path/to/your/upload/
            [full_path]    => /path/to/your/upload/jpg.jpg
            [raw_name]     => mypic2
            [orig_name]    => mypic2.jpg
            [file_ext]     => .jpg
            [file_size]    => 22.2
            [is_image]     => 1
            [image_width]  => 800
            [image_height] => 600
            [image_type]   => jpeg
            [image_size_str] => width="800" height="200"
    )
    [2] => array(
            ....
    )
)

Any ideas? I'm trying it now but no luck.
#2

[eluser]Fenix[/eluser]
anybody?
#3

[eluser]Italo Domingues[/eluser]
Hello Fenix, let me get this straight, you want to make a button where the user can click and thus add more fields of type file to upload images, is it?
#4

[eluser]Fenix[/eluser]
Yes but that isn't the hard part. That's easy. I was looking for confirmation that using a input name like image[] would work for multiple files. I have had no luck so far testing with Latavish's script (http://ellislab.com/forums/viewthread/80610/). Although I should still be able to dynamically make input names like image0, image1, image2, etc with JavaScript.
#5

[eluser]Italo Domingues[/eluser]
Look, I'm building an e-commerce, and the client can make multiple upload images, is the same thing you are doing, and about your question, yes you can use the image image[] by javascript, I use the jquery functions to implement ajax and javascript, if you want to make the script so I made some test, maybe I can help you.




Theme © iAndrew 2016 - Forum software by © MyBB