Forum: Ruby on Rails original filename doesn't display in file_field

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
cool_screen_name90001 (Guest)
on 2005-11-17 12:20
(Received via mailing list)
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.
gerret.apelt (Guest)
on 2005-11-17 12:44
(Received via mailing list)
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.


This topic is locked and can not be replied to.