full path of a uploaded file

hi

I am trying to get the "Full path of a uploaded file" . In my view I am using file_field to upload a file. Below is my view code

<table border="0" align="center">    <tr>      <td>       <label for="dump_file">         Select a CSV File :       </label>      </td>      <td >        <%= f.file_field :file -%>      </td>    </tr>    <tr><td></td><td></td></tr>    <tr>      <td colspan='2' align="center">        <%= submit_tag 'Submit' -%>      </td>    </tr> </table>

In a controller class when I try params[:dump][:file].original_filename it gives me only the filename of file. I need to parse the uploaded file(.csv file) in my controller. Can you please let me know how to get the full path of a file

you don't need that to parse the csv file.

something like this (in Model) will do:

attr_accessor :invitations_csv_file

  def upload_invitations     if invitations_csv_file && invitations_csv_file != "" then       CSV::Reader.parse(invitations_csv_file.read) do |parsed|         # do something here with the parsed content (fields in parsed[0], parsed[1]...)       end     end   end

In controller:

    @edition.invitations_csv_file = params[:file]     @edition.upload_invitations

hi shailey, just to add to thorsten's note: the uploaded file is passed as a UploadedStringIO to your controller. It's not saved anywhere, so there isn't a full path. You can save it yourself if you want, so it's up to you to choose the path. Or like thorsten suggests directly parse it and save its contents in the database in any structure you like.

dirk.