zerographik
zerographik

Reputation: 13

Blueimp jQuery-File-Upload - Upload doesn't want to start through custom button

I have created a custom Browse button titled Choose Image for my file upload.

When I click the button, the dialog opens, then I choose my files; But when I click Open within the file selection dialog, nothing happens.

It should send the upload request to server/php. How can I resolve this issue?

<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <title>jQuery File Upload Example</title>
    <link rel="stylesheet" href="css/style.css">
    <link rel="stylesheet" href="css/jquery.fileupload-ui.css">
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
    <script src="js/vendor/jquery.ui.widget.js"></script>
    <script src="js/jquery.iframe-transport.js"></script>
    <script src="js/jquery.fileupload.js"></script>
    <script src="js/jquery.fileupload-ui.js"></script>
</head>
<body>
    <script>
    $(function () {
        $('.btn').click(function() {
            return false;   
        });
        $('#fileupload').fileupload({
            dataType: 'json',
            acceptFileTypes: /(.|\/)(gif|jpe?g|png)$/i,
            done: function (e, data) {
                $.each(data.result, function (index, file) {
                    $('<p/>').text(file.name).appendTo(document.body);
                });
            }
        });
        $('#fileupload').bind('fileuploadstart', function (e, data) {
            alert('start !');
        }).bind('fileuploaddone', function (e, data) {
            alert('done !');
        });
    });
</script>
<form id="fileupload" action="server/php" method="POST" enctype="multipart/form-data">
    <div class="btn-upload nice small button blue radius fileinput-button">
        <span>Choose Image</span>
        <input type="file" name="files[]" multiple>
     </div>
</form>
</body> 
</html>

Upvotes: 1

Views: 2825

Answers (2)

Bob Cavezza
Bob Cavezza

Reputation: 2850

<input id="fileupload" type="file" name="files[]" data-url="server/php/" multiple> 

You are missing the data-url parameter in your html input element.

Upvotes: 0

Vladimir Cvetic
Vladimir Cvetic

Reputation: 842

fileupload needs to be placed on input field, not form element.

Upvotes: 3

Related Questions