Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Dec 2009
    Posts
    173
    Thanks
    24
    Thanked 1 Time in 1 Post

    [JQuery] Get files using ajax!

    How can i get the file using jquery ajax?

    body index
    <div id="content"></div>
    <input type="file" id="file" name="thefile" size="10"/>
    <input id="uploadbutton" type="button" value="Upload"/>
    js
    $(document).ready(function() {
    $("#uploadbutton").click(function() {
    var filename = $("#file").val();
    $.ajax({
    type: "POST",
    url: "upload.php",
    data : {file : filename},
    success: function(lol){
    $('#content').html(lol);
    }
    });
    });


    });
    upload.php file
    echo $_FILES['file']['name'];
    i can't deal with that red line code.

    the php file only outputs : "Undefined variable: file in C:\wamp\www\upme\upload.php on line 4"

    can u help me?
    Last edited by Kor; 03-31-2011 at 01:13 PM. Reason: Move the Thread in the proper Forum and adding a descriptive prefix

  • #2
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,396
    Thanks
    12
    Thanked 569 Times in 562 Posts
    Take a look at "jQuery File Upload" on http://aquantum-demo.appspot.com/file-upload


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •