我试图使用FormData类使用HttpRequest.send()将数据发送到我的服务器.我需要用多个字段做一个POST请求.它应该与此Javascript代码相同:
//Upload File
var uploadFile = function(file, tag, callback)
{
var xhr = new XMLHttpRequest();
xhr.open('POST', "upload/", true);
xhr.onreadystatechange=function()
{
if (xhr.readyState==4 && xhr.status==200)
{
callback();
}
}
var formData = new FormData();
formData.append('file', file);
formData.append('tag', tag);
var csrftoken = $.cookie('csrftoken');
xhr.setRequestHeader("X-CSRFToken", csrftoken);
xhr.send(formData);
};
Run Code Online (Sandbox Code Playgroud)
但是在Dart中,FormData似乎没有相同的工作方式.如果有可能,有人可以解释如何在Dart中执行此操作吗?