我需要使用blob将图像文件上传到服务器,但上传后的文件名总是设置为“blob”,或者在下载时,源代码文件的名称+.jpg。我的代码在 Chrome 上工作,但我需要它在 IE10 上工作,不幸的是我不知道如何。
我做的是这样的:
function uploadBlob() {
var fileName = //insert method to get the original filename of the file uploaded here...
var blob = dataURItoBlob(dataURL); //this method gets an image, compresses it and returns it as blob
var blob2 = new Blob([blob], { type: "image/jpeg" });
blob2.lastModifiedDate = new Date();
blob2.name = fileName;
return blob2;
}
使用 File Constructor 会容易得多,但 IE 和 Edge 不支持它。该函数需要返回一个文件或一个 blob,并且使用我当前的代码上传到服务器就好了,只是文件名不正确。我怎样才能解决这个问题?
POPMUISE
相关分类