Welcome Guest, Not a member yet? Register   Sign In
File upload class + ajax jquery

Hi all

I use the file upload class and it's work perfecly but I would like to use ajax jquery code to call the controller because I want to make small progress bar to let user know the file is currently in progress....

The javascript code

var userfile = document.getElementById("userfile").value;
// the userfile is the id of the input

   type: "POST",
   url: "index.php/inscription/postfile",
   data: ({
            userfile: userfile,
   success: function(msg){
    // alert( "File saved: " + msg );


The php controller
function postfile()

        $is_logged_in = $this->session->userdata('is_logged_in');
        $config['upload_path'] = './uploads/';
        $config['allowed_types'] = 'gif|jpg|png';
        $config['max_size']    = '100';
        $config['max_width']  = '1024';
        $config['max_height']  = '768';
        $this->load->library('upload', $config);
        if ( ! $this->upload->do_upload())
            $error = array('error' => $this->upload->display_errors());
             echo "Error :".$error;
            $data = array('upload_data' => $this->upload->data());
            echo "Succes";  

            echo "Not allowed to send file";

it's not working..... if I use the file upload class only work perfecly ....it is possible to archive this?

thanks for your help.

hi check the link will help you for your problem jquery uploadify working with CI


also check this forum post


Theme © iAndrew 2016 - Forum software by © MyBB