我需要使用blob將圖像文件上傳到服務(wù)器,但上傳后的文件名總是設(shè)置為“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 不支持它。該函數(shù)需要返回一個文件或一個 blob,并且使用我當(dāng)前的代碼上傳到服務(wù)器就好了,只是文件名不正確。我怎樣才能解決這個問題?
在上傳之前將文件名設(shè)置為 blob
喵喵時光機
2021-10-14 13:48:59