cant append e.target.files[x] to FormData in react.js

Viewed 173

I have this function which I Invoke onChange:

performSavePhoto(e){
    let photosToSave = e.target.files;

    let doUpload = (photoToUpload) => {

        console.log('doUpload', photoToUpload, typeof photoToUpload)

        var formData = new FormData();
        formData.set(photoToUpload.name, photoToUpload,photoToUpload.name)
        

        console.log(formData,'de form data')

    }



    let file = null;
    for (file in photosToSave){
        doUpload(photosToSave[file])
        console.log('for in', )
    }

}

I Invoke PerformSavePhoto onChange of file input, when Im trying to append this file, I get FormData.set: Argument 2 does not implement interface Blob. error, when I try to use .append method, I get the same error, anyone can help? I`m not event trying to send this via ajax, I get an error when I try append file to form data

0 Answers
Related