上传 IO 错误(django-filebrowser)

发布于 2024-11-10 03:11:43 字数 1551 浏览 0 评论 0原文

我在尝试使用 django-filebrowser (使用 uploadify)上传文件时收到“IO 错误”。

我应该澄清的是,唯一不起作用的情况是在 OSX 上使用 Firefox 4 时。 Windows 上的 IE8 可以工作。

此外,当使用本地开发服务器时,它也适用于 Firefox。

我还应该注意到,我在 uplodify 自己的网站演示中收到了这个确切的错误。

这是我从wireshark中看到的:

POST /djadmin/filebrowser/check_file/ HTTP/1.1
Host: xxx
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:2.0.1) Gecko/20100101 Firefox/4.0.1
Accept: application/json, text/javascript, */*
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip, deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
X-Requested-With: XMLHttpRequest
Referer: xxx
Content-Length: 57
Cookie: csrftoken=xxx sessionid=xxx
Authorization: Basic xxx
Pragma: no-cache
Cache-Control: no-cache

UPBWID=fd.png&folder=%2Fdjadmin%2Ffilebrowser%2Fupload%2FHTTP/1.1 200 OK
Date: Thu, 26 May 2011 20:08:30 GMT
Server: Apache/2.2.9
Vary: Accept-Language,Cookie
Content-Language: el
Content-Length: 2
Connection: close
Content-Type: text/html; charset=utf-8

{}

据我所知,返回值{}是可以的。

这是我从 apache 得到的唯一输出: xxx - 用户 [26/May/2011:20:08:30 +0000] "POST /djadmin/filebrowser/check_file/ HTTP/1.1" 200 2 "xxx/djadmin/filebrowser/upload/" "Mozilla/5.0 (Macintosh;英特尔 Mac OS X 10.6;2.0.1) Gecko/20100101 Firefox/4.0.1"

我可以看到很多人都遇到了同样的问题。 通常归咎于 mod_security、mod_wsgi 以及与浏览器/flash 插件的模糊不兼容性。

没有运行mod_security。 我正在使用 mod_wsgi 运行 django (并且以老式方式上传文件没有任何问题)。

请帮忙!

I am getting a 'IO ERROR' while trying to upload a file using django-filebrowser (that uses uploadify).

I should clarify that the only case when this doesn't work is when using Firefox 4 on OSX.
IE8 on windows works.

Also, it works with Firefox too when using the local dev server.

I should also note that i am getting this exact error on uplodify's own website demo.

This is what i can see from wireshark:

POST /djadmin/filebrowser/check_file/ HTTP/1.1
Host: xxx
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:2.0.1) Gecko/20100101 Firefox/4.0.1
Accept: application/json, text/javascript, */*
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip, deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
X-Requested-With: XMLHttpRequest
Referer: xxx
Content-Length: 57
Cookie: csrftoken=xxx sessionid=xxx
Authorization: Basic xxx
Pragma: no-cache
Cache-Control: no-cache

UPBWID=fd.png&folder=%2Fdjadmin%2Ffilebrowser%2Fupload%2FHTTP/1.1 200 OK
Date: Thu, 26 May 2011 20:08:30 GMT
Server: Apache/2.2.9
Vary: Accept-Language,Cookie
Content-Language: el
Content-Length: 2
Connection: close
Content-Type: text/html; charset=utf-8

{}

As far as i know, a return value of {} is ok.

This is the only output i get from apache:
xxx - user [26/May/2011:20:08:30 +0000] "POST /djadmin/filebrowser/check_file/ HTTP/1.1" 200 2 "xxx/djadmin/filebrowser/upload/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:2.0.1) Gecko/20100101 Firefox/4.0.1"

I can see that a lot of people are experiencing the same issue.
Usual blame goes to mod_security, mod_wsgi and vague incompatibilities with browsers/flash plugin.

I am not running mod_security.
I am running django using mod_wsgi (and don't have any trouble uploading files the old fashioned way).

Please help!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

唱一曲作罢 2024-11-17 03:11:43

您可能会遇到问题,即您没有发布 post 方法所需的 csrf 令牌。您可以使用@csrf_exempt装饰器,或者将数据添加到uploadify。将 {% csrf_token %} 添加到您的表单中,并将表单序列化为 postData 设置。对于第三版,我使用的是这样的东西:

(function ($) {
    $.fn.serializeJSON = function () {
        var json = {};
        jQuery.map($(this).serializeArray(), function (n, i) {
            json[n['name']] = n['value'];
        });
        return json;
    };
})(jQuery);


$('#id_filefield').uploadify({
    'swf'  : '{{ STATIC_URL }}js/libs/uploadify/uploadify.swf',
    'uploader'    : '{% url 'upload_form' %}',
    'cancelImage' : '{{ STATIC_URL }}js/libs/uploadify/uploadify-cancel.png',
    'checkExisting' : false,
    'auto'      : true,
    'postData': $('#file_upload_form').serializeJSON(),
    'multi': true,
    'uploaderType': 'flash',
    'requeueErrors': false,
    'fileObjName': 'filefield',
    'fileSizeLimit': 1024000,
    'onSelect': function() { $('#id_filefield').uploadifySettings('postData',   $('#file_upload_form').serializeJSON()); },
    'onQueueComplete': function() { ajaxdialog.dialog('close'); },
  });

显然你不想只是剪切和粘贴它,但它应该让你了解我在说什么。

You may be having an issue where you're not posting the csrf token that's required on post methods. You can use the @csrf_exempt decorator, or add the data to uploadify. add a {% csrf_token %} to your form and serialize the form to the postData setting. For version three I'm using something like this:

(function ($) {
    $.fn.serializeJSON = function () {
        var json = {};
        jQuery.map($(this).serializeArray(), function (n, i) {
            json[n['name']] = n['value'];
        });
        return json;
    };
})(jQuery);


$('#id_filefield').uploadify({
    'swf'  : '{{ STATIC_URL }}js/libs/uploadify/uploadify.swf',
    'uploader'    : '{% url 'upload_form' %}',
    'cancelImage' : '{{ STATIC_URL }}js/libs/uploadify/uploadify-cancel.png',
    'checkExisting' : false,
    'auto'      : true,
    'postData': $('#file_upload_form').serializeJSON(),
    'multi': true,
    'uploaderType': 'flash',
    'requeueErrors': false,
    'fileObjName': 'filefield',
    'fileSizeLimit': 1024000,
    'onSelect': function() { $('#id_filefield').uploadifySettings('postData',   $('#file_upload_form').serializeJSON()); },
    'onQueueComplete': function() { ajaxdialog.dialog('close'); },
  });

obviously you don't want to just cut and paste this, but it should give you an idea of what i'm talking about.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文