CodeIgniter Forums
multiple files upload not working? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: multiple files upload not working? (/showthread.php?tid=73999)



multiple files upload not working? - kvanaraj - 07-05-2019

I want to upload multiple files and upload in database.
Code:
<input type="file" name="files1" id="file0" accept="application/pdf" />
<input type="file" name="files2" id="file0" accept="application/pdf" />
<input type="file" name="files3" id="file0" accept="application/pdf" />
<input type="file" name="files4" id="file0" accept="application/pdf" />
<input type="file" name="files5" id="file0" accept="application/pdf" />

public function upload()
    {
        $this->data['notification'] = '';

        if( $this->input->post('btn_contact_details') )
        {
            // loading helpers

            $this->load->helper(array('form', 'url'));

            //setting the config array, for more options see Codeigniter docs

            $config['upload_path']          = './asset/images/upload/';      // upload path
            $config['allowed_types']        = 'pdf';   // allowed file types

            // loading upload library with config array
            $this->load->library('upload', $config);

            // uploading the files, lets_upload() is defined below

            $this->lets_upload('files1');
            $this->lets_upload('files2');
            $this->lets_upload('files3');
            $this->lets_upload('files4');
            $this->lets_upload('files5');
        }


        $this->load->view('auth/modal', $this->data);   

    }
public function lets_upload( $field_name )    
    {
        if ( ! $this->upload->do_upload( $field_name ))    
        {
            $this->data['notification'] .= $this->upload->display_errors();     
        }
        else        // if uploading success
        {
            $upload_data = $this->upload->data();     

            $this->data['notification'] .= $upload_data['file_name']." is successfully uploaded.<br>";     
        }
    }
Nothing upload in path . how to check it.need suggestion


RE: multiple files upload not working? - InsiteFX - 07-05-2019

Do you ever search Google or do you just come here and hope you will get the answer to your question?

How to upload Multiple Files and Images in CodeIgniter


RE: multiple files upload not working? - kvanaraj - 07-06-2019

(07-05-2019, 04:30 AM)InsiteFX Wrote: Do you ever search Google or do you just come here and hope you will get the answer to your question?

How to upload Multiple Files and Images in CodeIgniter

I am not asking multiple files to be uploaded at a time. If u know answer reply  otherwise don't make stupid reply.
"you just come here".


RE: multiple files upload not working? - php_rocs - 07-06-2019

@kvanaraj,

Maybe this link will help you... https://stackoverflow.com/questions/8377218/upload-multiple-files-in-codeigniter/8381575#8381575

Once you get the files uploaded to a particular place on the server then you can add them to the related database record.


RE: multiple files upload not working? - Wouter60 - 07-07-2019

Make sure your form has this opening tag:
PHP Code:
<form method="post" action="some_action" enctype="multipart/form-data" /> 

Put this code at the top of your lets_upload method:
PHP Code:
echo '<pre>';
print_r($_FILES);
echo 
'</pre>';
die(); 

This will show you the file data from your view.
Once you get this part working, you can remove this piece of code.