...

jQuery Uploading Files

tosbourn
11-14-2008, 03:18 PM
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...

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.

NancyJ
11-14-2008, 05:06 PM
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/04/465-asynchronous-file-upload-with-php-javascript-iframe.html

tosbourn
11-17-2008, 09:07 AM
Thank you so much, I was leaning towards using an iframe but try to avoid them unless I absolutely have to!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum