Hello,
#1. You can''t upload files using AJAX.
#2. The "IFRAME" trick is as follows:
- Create a template
- ...add an <IFRAME> which points to a URL with the HTML content to upload
a
file (multipart form, etc)
When you click "Upload" from within the iframe, only that
"frame"/"page" is
reloaded... and if you remove iframe borders, etc... it will look seamless.
You can have the iframe call javascript in the parent frame before and after
the upload as you wish.
AJAX comes into play (regarding the progress meter) by requesting progress
details from the server while the upload is occurring. IE:
#1. User selects a file to upload
#2. The "Upload" button calls a function in the parent frame
indicating the
upload is about to begin, and then submits the form.
#3. The parent frame acknowledges that the upload has started and uses AJAX
to ask the server for progress details ever N seconds.
#4. When the upload is complete, the Iframe reloads, and another function
from the parent window is called (from the Iframe) to indicate the upload is
done.
#5. The parent window stops requesting progress details and you''re all
set.
Adam
On 10/26/05, Martin DeMello
<martindemello-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:>
> The UploadProgress helper seems a bit fiddly (and is marked
> experimental), plus it won''t work on webrick; all I really need is
a
> way to upload a file via AJAX without doing a page refresh (e.g. like
> gmail''s "attach a file"). I''ve found several
references to an "iframe
> trick" but I couldn''t quite figure it (heck, it took me hours
to
> figure out why the file field wasn''t showing up in the params when
I
> AJAXed the form) - does anyone have a minimal example of just
> uploading a file using an AJAX form post?
>
> martin
> _______________________________________________
> Rails mailing list
> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
_______________________________________________
Rails mailing list
Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/rails