One common way to make asynchronous file upload that I could find on the web works as follow :
myUpload(ev) {
ev.preventDefault();
const data = new FormData();
data.append('file', this.uploadInput.files[0]);
/* Do the upload with something like axios */
axios.post('http://localhost:8000/upload', data)
. ...
}
I cannot explain the following :
- the object
this.uploadInput.files[0]
is aFile
javascript object. - From the documentation I could find (see for instance this), and from the log I tried on the console, javascript File objects store neither the file content, nor the file path.
Therefore, how can the FormData object retrieve the file data we want to send ?