问题描述
- html5 XMLHttpRequest上传文件,后台获取不到文件
-
在线等解答方法:
function saveFile(){
var zTree = $.fn.zTree.getZTreeObj("file_type_tree");
var nodes = zTree.getSelectedNodes();
//var str_title = $("#file_real_name").value;
var str_title = "测试";
var url = window["imageLoadPath"] + "/ResServer.aspx?uid=" + window["uid"] + "&key=" + window["key"]
+ "&title=" + str_title + "&fkid=" + nodes[0].FKID + "&fgid=" + nodes[0].FGID + "&tm=" + (new Date()).getTime() ;
var fd = new FormData();
//fd.append("fileToUpload", files[0]);
var file = files[0];
var xhr = new XMLHttpRequest();
//xhr.upload.addEventListener("progress", uploadProgress, false);
xhr.addEventListener("load", uploadComplete, false);
xhr.addEventListener("error", uploadFailed, false);
xhr.open("GET", url , true);
xhr.send(file);
}
解决方案
解决方案二:
xhr.open("GET", url , true);
上传文件怎么能用get,应该用post
时间: 2025-01-24 10:11:03