views:

32

answers:

2

hi

i am using an array of file, i mean input type ="file" to upload number of files at a time.

i want to print or echo that file array values , how can i do this.

please help me

Thanks

+1  A: 

You can create an array by suffixing [] to the name of the field:

<from method="POST" enctype="multipart/form-data">
 <input type="file" name="myfile[]" />
 <input type="file" name="myfile[]" />
 <input type="file" name="myfile[]" />
 <!-- and so on -->
 <input type="submit" name="submit" value="Submit" />
</form>

PHP

if (isset($_POST['submit']))
{
 print_r($_FILES['myfile']);
}
Sarfraz
how do i get the first array index file namei mean the first array element nameor how to echo the first element of that arrayeg: $_FILES['myfile']['name']but how in the case of an array??or how to echo the first element of that array
tibin mathew
@tibin: You can do like `echo $_FILES['myfile'][0]`
Sarfraz
Are u sure this will work. But its not working for me
tibin mathew
@tibin mathew: I don't know what are you doing, please show the relevant html and php code.
Sarfraz
This is the html code<input type="file" name="frm_image[]" class="text_area">Below is the php codeecho $_FILES['frm_image'][0];
tibin mathew
@tibin: have you added the `enctype="multipart/form-data"` to the `form` tag? see my answer above.
Sarfraz
+1  A: 

Do you mean this?

var_dump($_FILES['myfield']);
deceze