• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
multiple files upload not working?

#1
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
Reply

#2
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
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply

#3
(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".
Reply

#4
@kvanaraj,

Maybe this link will help you... https://stackoverflow.com/questions/8377...75#8381575

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

#5
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.
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.