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.

1
  • You could look at the following answer: stackoverflow.com/questions/1175347/… . Note, it is quite a "new" feature, so older browsers might not support the multiple feature. Commented Oct 10, 2013 at 23:56

2 Answers 2

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

Sign up to request clarification or add additional context in comments.

2 Comments

While I appreciate your answer. According to the documentation I would still need multiple inputs which isn't really a solution to my problem.
Sorry I forgot one little thing :) multiple="" try it now
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.

3 Comments

just remember quoted from W3Shools 'The multiple attribute is supported in Internet Explorer 10, Firefox, Opera, Chrome, and Safari'...if you want <IE10 than flash would be used
@gwillie, I think you didn't read my answer properly, I've already mentioned it.
uhm i scanned but certainly didnt take it in, obviously...my apologises

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.