javascript - After JS uses canvas to compress the image, the blob file generated is uploaded to the background and the originalFilename information of the file cannot be obtained.
PHP中文网2017-05-19 10:09:51
0
3
963
Input files[0] can get filename and originalFilename
But after it is compressed, it cannot be retrieved
After the image is compressed by canvas, all you get is the file itself without any name information. You can add a field and pass the name to the backend when submitting;
var formdata = new FormData(); formdata.append('0', blod); formdata.append('filename', file.filename);
The formData append method has a third parameter, which is used to set the filename for the blob you construct. The filename parameter has compatibility issues with some Android 4.x devices.
After the image is compressed by canvas, all you get is the file itself without any name information. You can add a field and pass the name to the backend when submitting;
The formData append method has a third parameter, which is used to set the filename for the blob you construct. The filename parameter has compatibility issues with some Android 4.x devices.
MDN API
You can take a look at the content I summarized about image uploading. I hope it will be useful to you.
Please click me for the link