[SOLVED] Cannot create a Parse.File with that data

i am working with moralis file using react hooks ** useMoralisFile()** i face this error Cannot create a Parse.File with that data.

Here is My Upload Function


   function uploadFiles(){
    saveFile("abdul.jpeg", fileToUpload)
  }

Code

const App = () => {
  const {Moralis} = useMoralis()
  const {error, isUploading, moralisFile, saveFile } = useMoralisFile()
  const [fileToUpload, setUploadFile]  = useState("")
  {
    //this is not  related
    //const addres = ' 0xAbEd40f031918D090c11a3ac4Bee9af76fB35cD4'
  }
  

   function uploadFiles(){
    saveFile("abdul.jpeg", fileToUpload)
  }
  {error && alert( error.message )}
     if(isUploading){
       return <h1>you currently uploading metadata</h1>
     }
  return <div>
  <h1>Let's Build Dapps using Moralis</h1>
  <input type='file' 
  name='file'
  onChange = {((e) => setUploadFile(e.target.value))}
  />
  <button className='save' onClick={uploadFiles}> save file</button>
  {moralisFile}
    </div>;
}

in vanilla js it is something like this: moralisFile = new Moralis.File("moralis_file_.png", document.getElementById("avatar").files[0]);

maybe it didn’t get to the file content with e.target.value

I think that’s the problem but I still haven’t got the idea to solve it Please show me an example of how you can solve
it in react

try to find out how to get the data for a file in react in general, I don’t know yet how to do that in react

Oo! i had To Use e.target.files[0] instead of e.target.value

:grin:

1 Like