File Upload - Preserving Original File Name

doug
Tue, 09 Mar 2010 02:56:33 -0000

I am using the following line of code in an action to provide a file
upload capability.

File.open(params[:upload_directory]+''/''+''test1'',''wb''){|f|
f.write(params[:file2upload].read)}

Admittedly, I''m not real clear on exactly how the above line works;
but, it does work.  I''m wondering if there is any way I can get at the
original file name (i.e., the name of the file on the system from
which the file is being uploaded) so that I could substitute it for
''test1'' and thereby preserve the original file name.

Any suggestions would be appreciated.  Thanks.

            ... doug

--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org