JellyBelly
JellyBelly

Reputation: 2431

jQuery-File-Upload - not work with any elements?

Here: https://github.com/blueimp/jQuery-File-Upload/wiki/Frequently-Asked-Questions

i read this: If you define the url (and probably paramName) Options, you can call the plugin on any element - no form or file input field required - and the drag&drop functionality will still work.

I tried this code:

JS

$(".resultUpload").each(function () {    
    $(this).fileupload({
        url: '/results/upload-ajax',
        formData: {
            //staff
        },
        dataType: 'json',
        maxFileSize: 10000000, // 10 MB
        paramName: 'fileupload',
        fileInput: $('input:file'),
        basic: true,
        maxNumberOfFiles: 1,
        done: function (e, data) {
            console.log('done');
            //staff
        },
        progressall: function (e, data) {
            console.log('progressall');                
            //staff
        },
        fail: function (e, data) {
            console.log('fail');                                
            //staff
        }
    });
});

HTML

    <div class="span3">
    <label>Attachment</label>
    <div class="file-upload">   
        <span class="btn btn-inverse fileinput-button">
            <span>Select File</span>        
            <input type="text" buttontext="Select File" class="resultUpload span12" value="" id="attachment" name="attachment"/>    
        </span>
        <br/>
        <br/>
        <!-- The global progress bar -->
        <div class="progress progress-success progress-striped">
        <div class="bar"></div>
    </div>
</div>

jsfiddle: http://jsfiddle.net/JellyBelly/hHZUq/

If i click on the button not open the window to browse the file. where am I wrong?

If i change the input type to file work.

Thanks

Upvotes: 1

Views: 1282

Answers (1)

JellyBelly
JellyBelly

Reputation: 2431

I received a reply from the developer of the plugin:

It says even without a file input, the drag&drop functionality will still work. The dialog for browsing files requires a file input.

Upvotes: 1

Related Questions