ed209
ed209

Reputation: 838

Codeigniter- upload more than one file with only one input field

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.

Upvotes: 0

Views: 1117

Answers (2)

webduvet
webduvet

Reputation: 4292

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

Upvotes: 2

The Alpha
The Alpha

Reputation: 146201

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.

Upvotes: 1

Related Questions