felixrieseberg / React-Dropzone-Component

:camera: ReactJS Dropzone for File Uploads (using Dropzone.js)
MIT License
1k stars 153 forks source link

How do I preload images into dropzone.js #172

Open Phathdt opened 6 years ago

Phathdt commented 6 years ago

It is programmatically instantiated, as it is part of a larger form. I have it trigged up to process the queue when the form is submitted.

The goal is for my users to be able to use the dropzone to manage images for an item, so when I load my 'models/edit' view for an item, I'd like to preload the dropzone with the images that had previously been uploaded for that item. Is there a good way to implement this so that the already-there items don't get re-uploaded when they submit their changes to the image list?

Phathdt commented 6 years ago

or just how to have some icon in init with name then I can you name to remove image from my component's state

danvc commented 6 years ago
var mockFile = { name: "Test.jpg", size: 150312 }; 
myDropzone.options.addedfile.call(myDropzone, mockFile);
MattSidor commented 6 years ago

Here's more info from the Dropzone.js documentation on creating a mock file: https://github.com/enyo/dropzone/wiki/FAQ#how-to-show-files-already-stored-on-server

And here's how to access the Dropzone object via the React component: https://github.com/felixrieseberg/React-Dropzone-Component#accessing-the-dropzone-object

MattSidor commented 6 years ago

Also! This issue thread may be helpful: https://github.com/felixrieseberg/React-Dropzone-Component/issues/6