0

I'm using hooks with filepond and I can't seem to extract the file from the filepond. My code is shown below. I know that my code is incorrect since the embed does not actually give the location of the file but I have no idea how to fix this.

const [files, setFiles] = useState([])
<FilePond
   files={files}
   allowMultiple={false}
   acceptedFileTypes={['application/pdf']}
   maxFileSize='10MB'
   onupdatefiles={fileItems => {
     const tmp = fileItems.map(fileItem => fileItem.file)
     setFiles(tmp)
     setContinue(tmp.length)
   }}
/>
<embed
   src={files[0] && files[0].name}
   type='application/pdf'
   width='100%'
   height='100%'
/>

I know I can use the filepond plugin with an image preview (FilePondPluginImagePreview), but it's not portable (can only be put inside the filepond) so I'm choosing not to use it.

EDIT:

console.log(files[0]) gives me this. This is the same thing as tmp[0].

Jerry Lee
  • 1
  • 1
  • 3
  • Hi, if you log `tmp` does the it show the file in the dev console? – Rik Dec 30 '19 at 10:28
  • Yep. tmp is logged as ```[File] 0: File name: "sample.pdf" lastModified: 1576895795045 lastModifiedDate: Fri Dec 20 2019 18:36:35 GMT-0800 (Pacific Standard Time) {} webkitRelativePath: "" size: 3028 type: "application/pdf" ```. However, when I log files[0], I get the same thing. – Jerry Lee Dec 30 '19 at 23:25

0 Answers0