jQuery Ajax File Upload

December 12, 2008 by admin · 10 Comments
Filed under: jQuery 

Ajax file upload plugin allows users to easily upload multiple files without refreshing the page. In addition, you can use any element to show file selection window.

This plugin creates invisible file input on top of the button you provide, so when user clicks on your button the normal file selection window is shown. And after user selects a file, plugin submits form that contains file input to an iframe. So it isn’t true ajax, but brings same user experience.


Advantages

  • AJAX like behaviour using iframe technique. (AJAX does not support file handling)
  • Multiple file upload
  • Allowed file types can be specified
  • Callback functions for all events
Dependencies jQuery 1.2
Size 4KB
Restrictions None (Free to use on any site)

For demo and download, please check the links

Open Demo | Open demo in new window | Info & Download

Related posts:

  1. Fancy Upload – Ajax file upload for MooTools
  2. jQuery Impromptu – alert and confirm replacement with form support
  3. How to make your forms better with jQuery?
  4. jQuery BlockUI Plugin
  5. Three jQuery modal plugins to repace alert and confirm

If you like this post, please share it so that others can also find this

Comments

10 Responses to “jQuery Ajax File Upload”
  1. valums says:

    This plugin supports prototype too.

  2. craig says:

    Nice work,

    A thumbnail preview of uploaded image would be nice.

  3. egetway says:

    nice ajax upload

  4. craig says:

    I got the thumbnail to display and remove image function. Check it out at

    http://www.diepbachduong.com/index.php/play/img

  5. miky says:

    Very nice !
    for craig, maybe you can share to us, your code.
    http://www.diepbachduong.com/index.php/play/img

  6. web designer says:

    very nice job, some pics resize it will be very useful, craig’s work is well done

  7. Selina says:

    Hi Craig,

    Is there any way you can share how you were able to implement the thumbnail and remove features? I tried it out, and it looks awesome!

    Thanks,
    Selina

  8. craig says:

    @miky
    @web designer
    @Selina

    Yes I can show you how.

    I am gonna tell you how the original script and my modification work.

    When you click a file name to upload, files/images are sent to and stored in server, “pic” folder. During this storing process, you capture the file name by PHP, then send the name back to browser, put it in the “src” attribute, that’s how you have image displayed on browser immediately.

    But, you have to resize the image to make it look nice and neat on browser, right? Therefore, before sending the file name back to browser, you have to resize the original image with PHP and rename with key word “thumb” attached to the original name, then store the thumb image in the same folder with original image. There u have the thumb now.

    To remove, during storing and resizing process, you send the id or the name of original image to browser and store it in JavaScript variable or in one of the element’s attributes, its your choice. So when u click remove link, you will get the name which was stored in browser, send to server, this is when server know what file name you want to delete. Meanwhile, in your Javascript code, put a snippet to hide/remove the link element and image element from browser view.

    Hope that makes sense. Anyway, if it’s too hard to figure out, you can contact me at craigcosmo@gmail.com to get the script.

Trackbacks

Check out what others are saying about this post...
  1. [...] Again, browser dependent thing which is almost impossible to style. Using Flash or Iframe, an Ajax effect can be achieved here. jQuery Plugins for Ajax upload [...]



Speak Your Mind

Tell us what you're thinking...
and oh, if you want a pic to show with your comment, go get a gravatar!