Jump to content

Upload multiple file

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
6 replies to this topic

#1
claudiu

claudiu

    Newbie

  • Members
  • PipPip
  • 11 posts
I have this code.
<form action="#" method="POST" enctype="multipart/form-data">
  <table border="0">
     <tr>
         <td><input type="file" name="images"></td>
         <td><input type="file" name="images"></td>
        <td><input type="file" name="images"></td>
    </tr>
  </table>
</form>
good, now i try to introduce images in folder I don't now how. give an example please


Thanks

Edited by Jaan, 04 August 2009 - 08:22 AM.
Please use code tags when you are posting your codes!


#2
kvs_mm

kvs_mm

    Newbie

  • Members
  • Pip
  • 3 posts
Ok. The first thing you must to do is to define a correct name.
To upload multiple file, you must use an array "[]", so, define the correct name for your fields "images[]". Then you need to go for each element of array "images" and upload it by using function "move_uploaded_file".

#3
kvs_mm

kvs_mm

    Newbie

  • Members
  • Pip
  • 3 posts
php[dot]net/move_uploaded_file

#4
amrosama

amrosama

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 8,674 posts
just like Kvs_mm said, you need to add the "[]" to the input name so it would look like this:

<form action="#" method="POST" enctype="multipart/form-data">

<table border="0">

<tr>

<td><input type="file" name="images[]"></td>

<td><input type="file" name="images[]"></td>

<td><input type="file" name="images[]"></td>

</tr>

</table>

</form>

on the server side use a loop to iterate through each uploaded file and move it. i recommend using a foreach loop
yo homie i heard you like one-line codes so i put a one line code that evals a decrypted one line code that prints "i love one line codes"
eval(base64_decode("cHJpbnQgJ2kgbG92ZSBvbmUtbGluZSBjb2Rlcyc7"));
www.amrosama.com | the unholy methods of javascript

#5
Guest_Jaan_*

Guest_Jaan_*
  • Guests
Just like he said..

<form action="#" method="POST" enctype="multipart/form-data">
  <table border="0">
     <tr>
         <td><input type="file" name="images[]"></td>
         <td><input type="file" name="images[]"></td>
        <td><input type="file" name="images[]"></td>
    </tr>
  </table>
</form>

and php file:

<?php

    $image = $_REQUEST['image'];
     
     foreach($image as $file){

          // Do your thing

     }

?>


#6
huda

huda

    Newbie

  • Members
  • Pip
  • 5 posts
please i want the php code

#7
Orjan

Orjan

    Writes binary right handed and hex left handed

  • Moderators
  • 3,299 posts

huda said:

please i want the php code

Um, the code is there?
__________________________________________
I study Information Systems at Karlstad University when I'm not on CodeCall