0

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

2 Answers 2

1

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']);
}
Sign up to request clarification or add additional context in comments.

5 Comments

how do i get the first array index file name i mean the first array element name or how to echo the first element of that array eg: $_FILES['myfile']['name'] but how in the case of an array?? or how to echo the first element of that array
@tibin: You can do like echo $_FILES['myfile'][0]
@tibin mathew: I don't know what are you doing, please show the relevant html and php code.
This is the html code <input type="file" name="frm_image[]" class="text_area"> Below is the php code echo $_FILES['frm_image'][0];
@tibin: have you added the enctype="multipart/form-data" to the form tag? see my answer above.
1

Do you mean this?

var_dump($_FILES['myfield']);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.