views:

362

answers:

2

My site allows users to upload csv files for processing. It all works fine, but on the response I'd like to report something like "Your file abc.csv processed OK".

Unfortunately I cannot seem to find the actual original file name in the params, even though Firebug tells me it's part of the post.

Any tips?

Thanks....

A: 

Try using debug on the results of your form.

http://guides.rubyonrails.org/debugging_rails_applications.html#debug

Jarrod
I dont see how that helps. I can tell the filename is not in the params hash by looking at the log.
Rob
I thought it might help breakdown where to look. After a little digging I found it in params[:your_file_field_name].original_filename.
Jarrod
Yes - just found that myself! Thanks.
Rob
+1  A: 

As Jarrod mentions in the comments above. Use params[:file].original_filename

Funny thing is, my form has two file upload tags (file1 and file2). One comes in as a ActionController::UploadedTempfile and the other ActionController::UploadedStringIO.

This may be a rails bug but it doesn't matter to me as both have the original_filename method.

Rob
The UploadedTempfile is probably Rails creating a temp file for an upload that's too large to keep in memory.
Jarrod