多个图片上传php代码

I have a script which is uploading images and creating thumbnails, but what I want is to upload multiple images and create thumbnails for each of them.

I think i have the problem here:

if(isset($_FILES['image'])) {

    $myImage = new _image;
    $myImage->uploadTo = 'uploads/';
    $res = $myImage->upload($_FILES['image']);
    if($res) {
        // RESIZE
        //$myImage->padColour = '#222222';
        $myImage->newWidth = 400;
        $myImage->newHeight = 300;
        $i = $myImage->resize();
        echo $i;
    }
} else {
    ?>
    <form action="" method="post" enctype="multipart/form-data" name="form1" id="form1">
        <p>
            <input type="file" name="image" id="image" />
        </p>
        <p>
            <input type="submit" name="button" id="button" value="Submit" />
        </p>
    </form>

I know that the input should be changed to multiple field, but I need for loop to create first.

I think I found what you are looking for. It's provided by formget.com and uses PHP & jQuery.

The first thing you want to do is to change..

<input type="file" name="image" id="image" />

..into

<input type="file" name="image[]" id="image" />

The benefit of image[] is, that they will be stored and delivered as an array.

So..

<input type="file" name="image[]" id="image" />
<input type="file" name="image[]" id="image" />
<input type="file" name="image[]" id="image" />

..will turn into something like this:

array(0 => img1, 1 => img2, 2 => ...)

try this code....

<input type="file" name="file[]" multiple />

php code :-

for($p=0;$p&lt;count($_FILES['file']['name']);$p++){

    echo $_FILES['file']['name'][$p];
    echo "<br />";

}   

i think this will help you....