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 3 of 3
  1. #1
    Regular Coder
    Join Date
    Aug 2008
    Location
    Northern Ireland
    Posts
    167
    Thanks
    12
    Thanked 6 Times in 6 Posts

    jQuery Uploading Files

    I am pretty much completely new to jQuery and I have a quick question regarding getting certain attributes.

    I want to allow file uploads via one particular form, however I would like it if the form could be handled in the same way all other forms are on this project (they are not submitted using HTML, all is done using jQuery and $.post)

    I am not sure if this is even possible, but is there a way of grabbing the file contents, size and type from within jQuery - doing something like...

    Code:
    alert($("#file").val());
    Return the filename but nothing else (unless this is the first element of an array, and if so how do I access the other elements?

    Cheers in advance.

  • #2
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,174
    Thanks
    19
    Thanked 66 Times in 65 Posts
    Its not possible to upload files via ajax. You can set your forms target to an iframe and upload the file without reloading the page but its not technically ajax.

    This tutorial explains the technique in detail with a few extras that aren't necessary http://www.chronosight.net/view/2006...pt-iframe.html

  • Users who have thanked NancyJ for this post:

    tosbourn (11-17-2008)

  • #3
    Regular Coder
    Join Date
    Aug 2008
    Location
    Northern Ireland
    Posts
    167
    Thanks
    12
    Thanked 6 Times in 6 Posts
    Thank you so much, I was leaning towards using an iframe but try to avoid them unless I absolutely have to!


  •  

    Posting Permissions

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