0

Is it possible with codeigniter, or even at all, to have only one input field that allows a user to select multiple files to upload. So basically you have

<input name="files" type="file">

rather than

<input name="file1" type="file">
<input name="file2" type="file">
<input name="file3" type="file">

I currently know how to implement the latter but think the former would be a cleaner model.

ed209
  • 788
  • 2
  • 12
  • 29
  • You could look at the following answer: http://stackoverflow.com/questions/1175347/how-can-i-select-and-upload-multiple-files-with-html-and-php-using-http-post . Note, it is quite a "new" feature, so older browsers might not support the multiple feature. – Styxxy Oct 10 '13 at 23:56

2 Answers2

2

Have you even looked into PHP manual?

<form action="file-upload.php" method="post" enctype="multipart/form-data">
  Send these files:<br />
  <input name="userfile[]" type="file" multiple=""/><br />
  <input type="submit" value="Send files" />
</form>

you access it in PHP as $_FILES

webduvet
  • 4,006
  • 2
  • 25
  • 39
  • While I appreciate your answer. According to the documentation I would still need multiple inputs which isn't really a solution to my problem. – ed209 Oct 10 '13 at 23:51
  • Sorry I forgot one little thing :) multiple="" try it now – webduvet Oct 11 '13 at 07:14
1

Your input has to be like this (so, you can select multiple files at once)

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

Notice multiple attribute but not supported by all/old browsers.

An Example here and also take look at this tutorial.

The Alpha
  • 131,979
  • 25
  • 271
  • 286
  • just remember [quoted from W3Shools](http://www.w3schools.com/tags/att_input_multiple.asp) 'The multiple attribute is supported in Internet Explorer 10, Firefox, Opera, Chrome, and Safari'...if you want – gwillie Oct 11 '13 at 01:09
  • @gwillie, I think you didn't read my answer properly, I've already mentioned it. – The Alpha Oct 11 '13 at 01:21
  • uhm i scanned but certainly didnt take it in, obviously...my apologises – gwillie Oct 11 '13 at 02:28