Note that there are some explanatory texts on larger screens.

plurals
  1. POCodeigniter Multi File Upload with HTML5, can it be done with tools like Uploadify?
    text
    copied!<p>Is it possible to do a multi file uploader using just HTML5 and PHP? I was hoping I could select multiple files, store them in a loop, and just iterate through all the files and upload them to the server.</p> <p>But Codeigniter only uploads the first file I selected.</p> <pre><code>foreach ($_FILES as $key =&gt; $value) { $this-&gt;upload-&gt;do_upload($key['name']) } </code></pre> <p>I have additional logic for handling stuff like upload path and file name, but that code is fine, but this loop seems to only work for the first select file and nothing else.</p> <p>If it's not possible to use HTML5 and php, I will just use Uploadify, or is there a way to modify the Upload Class to support multi file uploads?</p> <p>Here's my method more or less,</p> <pre><code>public function uploadScreens($id) { $this-&gt;load-&gt;library('upload'); $config['allowed_types'] = '*'; $config['max_size'] = '45000'; $config['max_width'] = '20000'; $config['max_height'] = '15000'; foreach ($_FILES as $key =&gt; $value) { if (!empty($key['name'])) { $this-&gt;db-&gt;set('gameid', $id); $this-&gt;db-&gt;insert('gamescreens'); $screenid = $this-&gt;db-&gt;insert_id(); $this-&gt;createDirectory($screenid); $filename = $this-&gt;randomFilename(); $config['file_name'] = "$filename"; $config['upload_path'] = APPPATH . "../content/gamescreens/" . $screenid . '/'; $this-&gt;upload-&gt;initialize($config); if ($this-&gt;upload-&gt;do_upload($key['name'])) { $data = $this-&gt;upload-&gt;data(); $sourceurl = $data["full_path"]; $this-&gt;db-&gt;simple_query("update gamescreens set source = '$sourceurl' Where id=$screenid"); } else { //catch eerrors } } } </code></pre> <p>}</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload