【问题标题】:jQuery file upload in codeigniter 3 shows 403 errorcodeigniter 3中的jQuery文件上传显示403错误
【发布时间】:2017-05-10 08:43:41
【问题描述】:

这是jquery文件上传的jquery代码,但返回403错误。

我正在使用 Codeigniter 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>');
            }
        });

【问题讨论】:

  • 向我们展示所有必要的代码。我们不知道$(this).data("url") 中有什么。您可能调用了错误的 url 或者您的 codeigniter 设置错误。
  • 是否启用了 CSRF 令牌?在config.php 下查看$config['csrf_protection'] = TRUE;
  • @jagad89 谢谢你成功了

标签: codeigniter codeigniter-3 jquery-file-upload


【解决方案1】:

现在工作正常,只是将 config.php 更改为 $config['csrf_protection'] = TRUE;$config['csrf_protection'] = false;

【讨论】:

    猜你喜欢
    • 2017-01-16
    • 1970-01-01
    • 2017-02-27
    • 2014-11-12
    • 1970-01-01
    • 2014-06-25
    • 1970-01-01
    • 2016-05-19
    • 1970-01-01
    相关资源
    最近更新 更多