I have a form.js redux-form that works and sends the data back to my API, but I also need to allow the sender to upload the image with the form, ideally with a preview. I did a bit of work and came to dropzone.js, but it looks like I canβt get my form in order to actually send image data back.
render () { const FILE_FIELD_NAME = 'files'; const renderDropzoneInput = (field) => { const files = field.input.value; return ( <div> <Dropzone name={field.name} onDrop={( filesToUpload, e ) => field.input.onChange(filesToUpload)} > <div>Try dropping some files here, or click to select files to upload.</div> </Dropzone> {field.meta.touched && field.meta.error && <span className="error">{field.meta.error}</span>} {files && Array.isArray(files) && ( <ul> { files.map((file, i) => <li key={i}>{file.name}<img src={file.preview}/></li>) } </ul> )} </div> ); } return ( <form onSubmit={this.props.handleSubmit(this.onSubmit)}> <div className="form-group"> <Field name="files" component={renderDropzoneInput} /> </div> <button type="submit" className="btn btn-default">Submit</button> </form> ); }
The files variable returns the POST back to the API, which is large, but contains the following:
[preview=blob:http://localhost:3000/bed3762e-a4de-4d19-8039-97cebaaca5c1]
Can someone tell me how I can get the actual binary data in this variable?
The full code is available here https://github.com/rushughes/dsloracle/blob/master/client/src/components/LandCreate/index.js
RusHughes
source share