weixiyen / jquery-filedrop

jQuery plugin - drag and drop desktop files and POST to a URL to handle files.
958 stars 285 forks source link

Button Click Open FileUpload Dialog available? #176

Open ZeroQool007 opened 9 years ago

ZeroQool007 commented 9 years ago

Can i click a button do open the file upload dialog?

barbeque commented 5 years ago

I had the same problem and the documentation wasn't extremely clear on it. What worked was something like this:

<div class="row" id="doc-uploader">
    <h1>Upload Documents</h1>
    <div id="upload-drop-target">
        <p>Drag here to upload</p>
    </div>
    <input type="file" id="drop-fallback" />
</div>

[...]

<script>
$('#upload-drop-target').filedrop({
                fallback_id: 'drop-fallback',
                fallback_dropzoneClick: true,
</script>

The key here was that the fallback element had to be a file (as jquery-filedrop listens to the change event) and not a button.

Hope this helps, although it has been nearly four years so I also hope you weren't waiting all this time for the answer. :)