我正在发出一个Ajax POST请求,但在我的视图中它没有被识别出来。在
代码输入视图.py公司名称:
^{1}$我的中间件设置是:
^{pr2}$我的javascript函数是:
function submitForm()
{
//document.forms["myForm"].submit();
xhrPost = getXhrObject();
var arrFiles = document.getElementById('id_file');
var fileToUpload = arrFiles.files[0];
xhrPost.onreadystatechange = function() {
if(xhrPost.readyState == 4 && xhrPost.status == 200)
document.getElementById("upload-progress-bar").innerHTML = xhrPost.responseText;
else
document.getElementById("upload-progress-bar").innerHTML = "processing upload...";
}
xhrPost.open("POST","/upload.psp/",true);
var boundary = "AJAX--------------" + (new Date).getTime();
var contentType = "multipart/form-data; boundary=" + boundary;
xhrPost.setRequestHeader("Content-Type", contentType);
xhrPost.setRequestHeader("X-CSRFToken", getCookie('csrftoken'));
xhrPost.send(fileToUpload);
return false;
}
谁能告诉我我缺少什么吗?为什么在我的“上传”功能里,请求没有被重新编码为“POST”views.py?在
提前谢谢。在
使用请求.raw_post_数据在你看来。像这样:
顺便说一下,我不知道如何分块获取文件。也许有人知道。在
相关问题 更多 >
编程相关推荐