Have a look at the approach taken by Sebastian Kanthak in his
file_column plugin [1]. When a file upload form had errors and needs
to be re-displayed, he uses a hidden field to reference the file that
had been previously uploaded to the server.
The ''value'' attribute of a form "file" input
represents only the name
of the file, not the file''s content [2] [3]. My guess is that not all
browsers will actually upload a file when you haven''t explicitly
selected it with the file input''s browse dialog (?). It does work in
Firefox though.
Gerret
[1] http://www.kanthak.net/opensource/file_column/
[2] http://www.cs.tut.fi/~jkorpela/forms/file.html
[3] http://www.faqs.org/rfcs/rfc1867.html
On 11/17/05, CSN
<cool_screen_name90001-/E1597aS9LQAvxtiuMwx3w@public.gmane.org>
wrote:> In my item upload view I have:
>
> <%= file_field ''item'', ''file'' %>
>
>
> and in my Item model:
>
> def file
> @file
> #@file.original_filename # <- also tried this
> end
>
> def file=(file)
> @file=file
> end
>
>
> And if the upload bails because of errors (and renders the same page), all
other fields
> (text_field, text_area, etc.) retain their inputted values, but the file
field is blank. Any idea
> what the problem is?
>
> I''m using this tutorial as a guide:
> http://manuals.rubyonrails.com/read/chapter/79
>
> thanks
> csn
>
>
>
> __________________________________
> Yahoo! FareChase: Search multiple travel sites in one click.
> http://farechase.yahoo.com
> _______________________________________________
> Rails mailing list
> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>