Search code examples
codeignitercodeigniter-3jquery-file-upload

jQuery file upload in codeigniter 3 shows 403 error


This is the jquery code for jquery file upload but it returns 403 error.

I'm using Codeigniter version 3.1.4

 $('.fileupload').fileupload({
            url: $(this).data("url"),
            dataType: 'json',
             async: true,
            done: function (e, data) {
                console.log('sry');
                if (data.result.status == true) {
                    console.log('helo');
                    $('#filename').html('');
                    $('#filename').val(data.result.file);


                }
                else {
                    $('.img_name').append('Try again!..');

                }
            },
            progressall: function (e, data) {
                console.log('uploading_msg');
                var progress = parseInt(data.loaded / data.total * 100, 10);
                console.log(progress);
                $('.progress_1').html('<div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="' + progress + '" aria-valuemin="0" aria-valuemax="100" style="width: ' + progress + '%"><span class="sr-only">' + progress + '% Complete (success)</span> </div>');
            }
        });

Solution

  • now working fine just changed config.php change $config['csrf_protection'] = TRUE; to $config['csrf_protection'] = false;