I am trying to upload image from angular using ngx-file-drop to the server site (https://www.file.io/) and here is what i have from the library documentation:
// Is it a file?
if (droppedFile.fileEntry.isFile) {
const fileEntry = droppedFile.fileEntry as FileSystemFileEntry;
fileEntry.file((file: File) => {
this.allfiles.push(droppedFile.relativePath);
const formData = new FormData()
formData.append('image', file, droppedFile.relativePath)
this.http.post('https://file.io/', formData)
.subscribe(data => {
// Sanitized logo returned from backend
})
});
} else {
// It was a directory (empty directories are added, otherwise only files)
const fileEntry = droppedFile.fileEntry as FileSystemDirectoryEntry;
console.log(droppedFile.relativePath, fileEntry);
}
I am not sure what to do in the following lines of code:
this.http.post('https://file.io/', formData)
.subscribe(data => {
// Sanitized logo returned from backend
})