问题:
Can I use the following jQuery code to perform file upload using POST method of an ajax request ? 我可以使用以下jQuery代码使用ajax请求的POST方法执行文件上传吗?
$.ajax({
type: "POST",
timeout: 50000,
url: url,
data: dataString,
success: function (data) {
alert('success');
return false;
}
});
If it is possible, do I need to fill data
part? 如果有可能,我是否需要填写data
部分? Is it the correct way? 这是正确的方法吗? I only POST the file to the server side. 我只将文件发布到服务器端。
I have been googling around, but what I found was a plugin while in my plan I do not want to use it. 我一直在搜索,但是我发现是一个插件,而在我的计划中我不想使用它。 At least for the moment. 至少目前是这样。
解决方案:
参考一: https://stackoom.com/question/9jYT/jQuery-Ajax文件上传参考二: https://oldbug.net/q/9jYT/jQuery-Ajax-File-Upload
来源:oschina
链接:https://my.oschina.net/u/3797416/blog/4334382