# Full path of a uploaded file

**URL:** <https://www.ruby-forum.com/t/full-path-of-a-uploaded-file/148015>\
**Category:** Rails\
**Created:** [September 8, 2008, 10:24am UTC](https://www.ruby-forum.com/t/full-path-of-a-uploaded-file/148015 "2008-09-08T10:24:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![shaily903](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c68b51/32.png) [@shaily903](https://www.ruby-forum.com/u/shaily903)\
**Post date:** [September 8, 2008, 10:24am UTC](https://www.ruby-forum.com/t/full-path-of-a-uploaded-file/148015/1 "2008-09-08T10:24:34Z")

</div>

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

| Select a CSV File : | \<%= f.file\_field :file -%\> |
| | |
| \<%= submit\_tag 'Submit' -%\> |

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

---

<div class="post-metadata">

**Author:** ![shaily903](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c68b51/32.png) [@shaily903](https://www.ruby-forum.com/u/shaily903)\
**Post date:** [September 8, 2008, 10:42am UTC](https://www.ruby-forum.com/t/full-path-of-a-uploaded-file/148015/2 "2008-09-08T10:42:30Z")

</div>

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
```

---

<div class="post-metadata">

**Author:** ![shaily903](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c68b51/32.png) [@shaily903](https://www.ruby-forum.com/u/shaily903)\
**Post date:** [September 8, 2008, 12:22pm UTC](https://www.ruby-forum.com/t/full-path-of-a-uploaded-file/148015/3 "2008-09-08T12:22:50Z")

</div>

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.
