Home How can I upload files asynchronously?
Reply: 0

How can I upload files asynchronously?

user954 Published in March 24, 2018, 12:46 am

I would like to upload a file asynchronously with jQuery. This is my HTML:

<input type="file" id="file" name="file" size="10"/>
<input id="uploadbutton" type="button" value="Upload"/>

And here my Jquery code:

$(document).ready(function () {
    $("#uploadbutton").click(function () {
        var filename = $("#file").val();

            type: "POST",
            url: "addFile.do",
            enctype: 'multipart/form-data',
            data: {
                file: filename
            success: function () {
                alert("Data Uploaded: ");

Instead of the file being uploaded, I am only getting the filename. What can I do to fix this problem?

Current Solution

I am using the jQuery Form Plugin to upload files.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.494914 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO