0

I want to upload file using jQuery, but I am getting an exception saying undefined is not a function at $('#myFile').ajaxForm({

HTML

<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
<script src="jquery-1.11.1.min.js"></script>
<script src="x.js"></script>
</head>
<body>
    <form enctype="multipart/form-data" action="/FileUploadUI5/upload"
        method="POST" id="myFile">
        <input type=file name=upfile><br> <input type="submit"
            name="Upload" value="Upload" id="ubutton" />
    </form>
</body>
</html>

X.js

$(document).ready(function() {
    $(function() {
        $('#myFile').ajaxForm({
            beforeSend : function() {
            },
            uploadProgress : function(event, position, total, percentComplete) {
                alert(position + "|" + total + "|" + percentComplete);
            },
            complete : function(xhr) {
                // status.html(xhr.responseText);
            }
        });
    });

    $('#ubutton').click(function(e) {
        $('#myFile').submit();
    });

});
musicnothing
  • 3,977
  • 24
  • 43
Arvind
  • 1,207
  • 6
  • 27
  • 55

1 Answers1

-2

I believe sending files is not available in pure jquery. I did it few days ago using plugins; http://rubaxa.github.io/jquery.fileapi/ or https://github.com/blueimp/jQuery-File-Upload

The first one is really impressive; i was able to do it in no time and visual progress indicatior and ability to use webcam for images is astonishing.

more in the topic You can find here, i think: How can I upload files asynchronously?

hope it helps :-)

Community
  • 1
  • 1
entio
  • 3,816
  • 1
  • 24
  • 39