Original filename doesn't display in file_field

In my item upload view I have:

<%= file_field ‘item’, ‘file’ %>

and in my Item model:

def file
#@file.original_filename # ← also tried this

def file=(file)

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:


Yahoo! FareChase: Search multiple travel sites in one click.

Have a look at the approach taken by Sebastian K. 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.


[1] http://www.kanthak.net/opensource/file_column/
[2] http://www.cs.tut.fi/~jkorpela/forms/file.html
[3] RFC 1867 - Form-based File Upload in HTML (RFC1867)