0

I am currently working on php project where I need to upload files, but I have no way of knowing how many files the user will upload.

There will be one file upload by default on the form with a link to add another file upload. When the form is submitted how would I post all of the files to the php script if I don't know the number of files that are being uploaded.

Does it work in the same way as a checkbox array so you could have something like

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

Thanks for any help you can provide.

Boardy
  • 35,417
  • 104
  • 256
  • 447

2 Answers2

1

Yes, it works exactly like a checkbox array.

Niet the Dark Absol
  • 320,036
  • 81
  • 464
  • 592
1

Yes, works fine.

try to do this, after post form with files:

<pre>
    <?php print_r($_FILES['myFile']['tmp_name']); ?>
</pre>

You will get a array. Access each file info with their index:

$_FILES['myFile']['tmp_name'][0];
$_FILES['myFile']['tmp_name'][1];
Gabriel Santos
  • 4,934
  • 2
  • 43
  • 74
  • Thanks I did try do that array thing that I mentioned in the question but it didn't work because I forgot to put set the form enctype. – Boardy May 27 '12 at 15:20