1

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>
2
  • do those alerts popup, witch u binded? Commented Sep 14, 2012 at 8:59
  • No, they don't popup... I exactly placed theses alerts to see what happens, to see if if it works. Commented Sep 15, 2012 at 7:21

2 Answers 2

3

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

Sign up to request clarification or add additional context in comments.

1 Comment

According to API (github.com/blueimp/jQuery-File-Upload/wiki/API) it shouldn't matter whether fileupload is called on the input field or the form.
0
<input id="fileupload" type="file" name="files[]" data-url="server/php/" multiple> 

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.