当我试图使用django-filebrowser上传一个文件时,我得到了一个'IO错误‘。
我要澄清的是,只有在OSX上使用Firefox 4时才会出现这种情况。windows上的IE8工作。
此外,当使用本地dev服务器时,它也可以与Firefox一起工作。
我还应该注意到,我得到了这个准确的错误上传自己的网站演示。
这就是我从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 - user 26/5/2011:20:08:30 +0000 :POST /djadmin/filebrowser/check_file/ HTTP/1.1“200 "xxx/djadmin/filebrowser/upload/”Mozilla/5.0“(Macintosh;Intel 10.6;rv:2.0.1) Gecko/20100101 Firefox/4.0.1”获得的唯一输出。
我可以看到,很多人都在经历同样的问题。通常归咎于mod_security、mod_wsgi和浏览器/闪存插件的模糊不兼容。
我不运行mod_security。我正在使用mod_wsgi运行django (使用老式方式上传文件没有任何问题)。
请帮帮我!
发布于 2011-05-26 20:36:46
您可能遇到了一个问题,您没有发布post方法所需的csrf令牌。您可以使用@csrf_exempt装饰器,也可以添加数据上传。向窗体添加{% 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'); },
});很明显,你不想只剪切粘贴这个,但它应该让你知道我说的是什么。
https://stackoverflow.com/questions/6144553
复制相似问题