Input files[0] can get filename and originalFilename
But after it is compressed, it cannot be retrieved
曾经蜡笔没有小新2017-05-19 10:11:51
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);
伊谢尔伦2017-05-19 10:11:51
formData.append(name, value);
formData.append(name, value, 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.
MDN API
淡淡烟草味2017-05-19 10:11:51
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