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中文网
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

PHP中文网
PHP中文网

认证高级PHP讲师

reply all (3)
曾经蜡笔没有小新

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);
    伊谢尔伦
    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

      淡淡烟草味

      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

        Latest Downloads
        More>
        Web Effects
        Website Source Code
        Website Materials
        Front End Template
        About us Disclaimer Sitemap
        php.cn:Public welfare online PHP training,Help PHP learners grow quickly!