How can i upload image with ajax in codeigniter?

前端 未结 4 901
隐瞒了意图╮
隐瞒了意图╮ 2020-12-16 06:46

I\'m trying to upload image with jQuery and ajax function, and how can I fetch all details of image file, like in php we use $_FILE()

Here is my code

4条回答
  •  被撕碎了的回忆
    2020-12-16 07:10

    You can use Ajaxfileupload.js to upload file:

    $('input[type="file"]').ajaxfileupload({
              'action': 'save_photo.php',
              'params': {
                'extra': 'info'
              },
              'onComplete': function(response) {
    
               console.log('custom handler for file:');
               alert(JSON.stringify(response));
    
              },
              'onStart': function() {               
    
              },
              'onCancel': function() {
                console.log('no file selected');
              }
        });
    

    save_photo.php :

    
    

提交回复
热议问题