Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I've run into what i think is a similar thing in the past.</p> <p>If you are looping through your uploaded files, with different <code>$config</code> for different files, you need to initialize the the upload class between each iteration:</p> <pre><code>$this-&gt;upload-&gt;initialize( $config ); </code></pre> <p>Do you have pastebin or something of a code sample?</p> <p>This is what I did in an earlier project to handle changing $config depending on file type:</p> <p>if( $_FILES ) { $this->load->library('upload');</p> <pre><code>foreach ( $_FILES as $key =&gt; $value ) { $file_type = ( $key == 'image' ) ? 'image' : 'document'; if( ! empty( $value['name'] )) { $config = array( 'upload_path' =&gt; './uploads/materials/' . strtolower($material['code']) . '/', 'allowed_types' =&gt; ($file_type == 'image') ? 'jpg|jpeg|png' : 'jpg|jpeg|png|pdf', 'max_size' =&gt; 1024 * 10, 'max_width' =&gt; 19200, 'max_height' =&gt; 12800, 'overwrite' =&gt; TRUE, ); // ------------------------------------------------------------------------ // Here is the key idea: You need to initialize each time you change the $config // ------------------------------------------------------------------------ $this-&gt;upload-&gt;initialize( $config ); if( $this-&gt;upload-&gt;do_upload( $key )) { //Success! Files are all uploaded. $uploaded = $this-&gt;upload-&gt;data(); $data['file_data'] = array( 'parent_id' =&gt; $data['material']-&gt;id, 'filename' =&gt; $uploaded['file_name'], 'filename_original' =&gt; $uploaded['client_name'], 'type' =&gt; $file_type, 'location' =&gt; $config['upload_path'], 'description' =&gt; '', ); // Add the file details to the database $this-&gt;material-&gt;add_material_file( $data ); } else { // ERROR! Something went wrong... alert the user. $errors = $this-&gt;upload-&gt;display_errors(); $this-&gt;session-&gt;set_flashdata( 'flashError', $errors ); } } } </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