I'm trying to create a React app that reads a DICOM (.dcm) file from the user's computer and show it on a visor.
I manage to successfully pick the file using react-dropzone but i don't know how to get the file path in order to read it.
Checking other similar questions i read "you can only read the file in frontend, all manipulations must be done in backend" so i dont think i need to send the file to backend but i haven't been able to find an answer that works for me.
Here's my wrapper for dropzone:
<Dropzone multiple={false} onDrop={acceptedFiles => this.updateState(acceptedFiles)}>
{({ getRootProps, getInputProps }) => (
<section>
<div {...getRootProps()}>
<input {...getInputProps()} />
<p>
Drag 'n' drop some files here, or click to select
files
</p>
</div>
</section>
)}
</Dropzone>
Here's the updateState(acceptedFiles) method:
updateState(acceptedFiles) {
this.setState({Files:acceptedFiles});
// i use this state to control that i have read a file.
this.setState({leido:true});
console.log(this.state.Files);
console.log(this.state.leido);
this.state.Files.map(file => (
console.log(file.path)
))
};
this.state.Files becomes an array of one element, but the path is apparently the same as the file name. When i try to read a file i always get the same error on console:
GET http://localhost:3000/filename.format 404 (Not Found)
How can i get a proper path to read the file? It's not necesary to manipulate it in any way.