views:

29

answers:

3

Hi,

I have form that uploads file's perfectly, with a post-page-refresh-form.

However I have ajaxiefied the form with jquery's $.post

All of the data except for the file upload is saving nicely.

Is there somthing special I need to do to the form or in jquery to get the upload to work?

Thanks!

+4  A: 

You cannot upload with javascript (it would mean granting js file access on your computer, a no go from security standpoint). Uploadify has a nice solution.

Wrikken
+1  A: 

First off, I agree with Wrikken about Uloadify being a great solution.

But, yes, Javascript does not have access to upload files. There is a way around this by using Flash, but I would not go through all the trouble to build it yourself when there are other plugins out there that will take care of it all for you.

BigRossLabs
+1  A: 

You can make it "lookalike" AJAX. Use a hidden iframe and send your form into this iframe, you will be able to observe the onload of the iframe and get a response.

This way gives you also the option for an easy fallback if JS is disabled.

Dr.Molle
We used to use this indeed back in the good ol' days, but an upload form to a hidden iframe may be non-javascript, it is not really user-friendly to let them upload stuff without _any_ possibility to tell them that the upload failed, finished, whatever. That is what it would be like with no javascript (terrible confusing to users although it works).
Wrikken
You are wrong, it's very easy to leave anybody satisfied. Take a form and send this to _self-window(the NO-JS-way). With JS you only have to create the iframe and change the form's target-window to the iframe: anybody will be happy and able to get a response.
Dr.Molle
OK, I misunderstood / misread, I though you were claiming a hidden iframe as a non-js way, my apologies.
Wrikken