I need to upload image files to the server using blob, but the name of the file after uploading is always set to "blob" or, when downloading, the name of the source code file + .jpg. My code works on Chrome, but I need it to work on IE10 and unfortunately I don't know how.
What I do is this:
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;
}
This would be much easier with File Constructor, but IE and Edge don't support it. The function needs to return a file or a blob, and with my current code it uploads to the server just fine, it's just the file name isn't right. How can I get around this?
Your file upload is part of a request. You can pass filename as a separate parameter of the same request. If that's not an option for you, then you can create a request before uploading the blob, by sending in the filename and set a session variable which therefore will be known upon the next request, when the blob is uploaded. However, if possible, pass a filename parameter separately to the request, not just as the name of the blob, as it appears to be the bug in your case.