Closed gemon01 closed 4 years ago
Just hide the uploader upon the first successful upload and stop additional uploads via a variable somewhere in your code. If the user deletes the file, then reset the variable and show the uploader again. If the user adds more than one file to the list, you can remove any extras so that only one item is in the list. The documentation has sufficient examples to put this together although it's not specifically laid out.
Another option is to just let people upload multiple images and overwrite the one image on the server and trigger an image refresh in the browser on success. They'll quickly figure out that the widget only works with single images. There could also be text somewhere nearby that says, "Uploading will overwrite the existing image."
You need to handle file uploads idempotently anyway. This JS widget supports automatic retries of failed uploads. In your case, that means multiple incoming files should overwrite the same image.
Showing/hiding stuff in Javascript is done all the time. jQuery makes it pretty simple: $('#someelement').hide();
and $('#someelement').show();
.
hi, I'm trying to use the "FancyFileUpload" jquery plugin on my site to upload an image.
I would like to know if there is the possibility to link the upload to a single file.
in the parameters to pass to the plugin there is also
// jQuery File Upload options 'fileupload': {singleFileUploads:true}
I also thought about hiding the dropzone once I made the first upload, but if I delete the file after, how do I re-enable the dropzone?
which has a singleFileUploads property but it doesn't work .... or maybe I can't use it :-)