Topic: How to get the name of a file being uploaded?

Greetings all,
I have a form that our users use to upload a text file. This is in a very closed environment.  Only one or two employees ever use this form.   Everything is working fine, but I'd like to be able to verify they are uploading a .txt file. I've been searching/google for hours and have had no luck.  The closest I've come is using: upload['datafile'].original_filename, but that does not work with my setup.

My View:

<%= form_for :file_upload, :url => { :action => "micros_upload", :method => :post }, :html => { :multipart => true } do |f| %>
  <%= f.file_field('upload') %>
  <%= submit_tag 'Upload File' %>
<% end %>

My Controller:

def micros_upload
  @message =
  if params[:file_upload] 
    file_path = params[:file_upload][:upload].path
    @message = MicrosImport.micros_upload_from_file(file_path)

The model, MicrosImport has a method micros_upload_from_file() that processes the file passed in using FasterCSV.  The file is not saved to the server or a database.  I believe it goes to a tmp directory as a part of the upload, but we do not save it anywhere.   As noted, this works fine, but I'd like to add in a check to test the type (.txt).

Is there some "hidden field" in the params[:file_upload] that will give me the name of the file being uploaded?

Thanks for any insights.

Re: How to get the name of a file being uploaded?

I figured this out.

if params[:file_upload][:upload].original_filename.match(/\.txt/)
... process file...

I had tried the .original_file name before, but I doubt I was using the proper param names.  I did a view source on my form and found the input name was file_upload[upload] which becomes params[:file_upload][:upload] in the controller.