For the picture upload process, the front end asks for an explanation.

Image upload process. The front end asks for an explanation


1. inputonchange
2. formdata
3. POST
document.querySelector('-sharpfile').onchange = function(e) {
    if(e.files.length === 0) {
        return;
    }
    const fd = new FormData();
    fd.append('file',e.files[0]);
    
   fetch('http://www.baidu.com/upload').then(res=>console.log(res)).catch(console.error);
}

use formdata, View documents


want to hear how to explain.
there are many picture upload schemes

  1. oss Direct transfer Pure Front end Operation
  2. file object transfer background to do the rest of the upload processing
  3. Picture to base64 is being processed

my front end usually converts the picture into a base64 string, and when requesting the backend data interface, the base64 string is passed to the backend

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e4864f-44ca7.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e4864f-44ca7.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?