# Getting filename of upload

**URL:** <https://www.ruby-forum.com/t/getting-filename-of-upload/107524>\
**Category:** Rails\
**Created:** [June 22, 2007, 4:14pm UTC](https://www.ruby-forum.com/t/getting-filename-of-upload/107524 "2007-06-22T16:14:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![DavidB](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/76d3ee/32.png) [@DavidB](https://www.ruby-forum.com/u/DavidB)\
**Post date:** [June 22, 2007, 4:14pm UTC](https://www.ruby-forum.com/t/getting-filename-of-upload/107524/1 "2007-06-22T16:14:43Z")

</div>

Greetings,  
I have a method that processes an uploaded file, manages content\_type,  
and a few other things. How would I go about getting the filename of  
the uploaded file WITHOUT using javascript on the client side to send  
it through the form???

LiveHTTPHeaders sends the filename with ‘Content\_Disposition’. Looking  
through the API of CGI.rb, I still could not find an answer on how to  
capture the original filename from the client.

Thanks in advance.  
David

---

<div class="post-metadata">

**Author:** ![DavidB](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/76d3ee/32.png) [@DavidB](https://www.ruby-forum.com/u/DavidB)\
**Post date:** [June 22, 2007, 4:43pm UTC](https://www.ruby-forum.com/t/getting-filename-of-upload/107524/2 "2007-06-22T16:43:46Z")

</div>

i believe there is an “original\_filename” object that you can call on  
your file object.

file\_name = my\_file.original\_filename

hope that helps.

---

<div class="post-metadata">

**Author:** ![DavidB](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/76d3ee/32.png) [@DavidB](https://www.ruby-forum.com/u/DavidB)\
**Post date:** [June 22, 2007, 5:25pm UTC](https://www.ruby-forum.com/t/getting-filename-of-upload/107524/3 "2007-06-22T17:25:48Z")

</div>

Thanks-that is precisely what I was looking for. Next time, I will  
comb the docs more carefully.

THanks again, Josh.

David
