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

[eluser]Unknown[/eluser]
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
Code:
[removed]

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

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

[removed]

The php controller
Code:
function postfile()
    {
        

        $is_logged_in = $this->session->userdata('is_logged_in');
        if($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;
        }    
        else
        {
            $data = array('upload_data' => $this->upload->data());
            echo "Succes";  

        }
            
        }else{
            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.
#2

[eluser]umefarooq[/eluser]
hi check the link will help you for your problem jquery uploadify working with CI

http://www.reloadedpc.com/code-igniter/j...deigniter/

also check this forum post

http://ellislab.com/forums/viewthread/109751/




Theme © iAndrew 2016 - Forum software by © MyBB