# Problem with file upload

**URL:** <https://www.ruby-forum.com/t/problem-with-file-upload/139964>\
**Category:** Rails\
**Created:** [June 9, 2008, 4:52pm UTC](https://www.ruby-forum.com/t/problem-with-file-upload/139964 "2008-06-09T16:52:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![paulbutcher](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a5b964/32.png) [@paulbutcher](https://www.ruby-forum.com/u/paulbutcher)\
**Post date:** [June 9, 2008, 4:52pm UTC](https://www.ruby-forum.com/t/problem-with-file-upload/139964/1 "2008-06-09T16:52:43Z")

</div>

When I try a simple file upload and  
params[:image][:file\_name].original\_filename in the controller I get an  
error: “The error occurred while evaluating nil.original\_filename”. What  
could be wrong? The form is multipart \<% form\_tag :action =\>  
“create\_image”, :multipart =\> true do %\>

The file field is: \<%= file\_field ‘image’, ‘file\_name’ %\>

---

<div class="post-metadata">

**Author:** ![paulbutcher](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a5b964/32.png) [@paulbutcher](https://www.ruby-forum.com/u/paulbutcher)\
**Post date:** [June 9, 2008, 7:31pm UTC](https://www.ruby-forum.com/t/problem-with-file-upload/139964/2 "2008-06-09T19:31:52Z")

</div>

PÃ¥l BergstrÃ¶m wrote:

> When I try a simple file upload and  
> params[:image][:file\_name].original\_filename in the controller I get an  
> error: “The error occurred while evaluating nil.original\_filename”. What  
> could be wrong? The form is multipart \<% form\_tag :action =\>  
> “create\_image”, :multipart =\> true do %\>
> 
> The file field is: \<%= file\_field ‘image’, ‘file\_name’ %\>

Is it that params[:image][:file\_name] is just a string, not an object  
with the method original\_filename?

What does the rest of the controller code look like in the create? Have  
you done the @model = Model.new(params[:image]) yet?

---

<div class="post-metadata">

**Author:** ![paulbutcher](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a5b964/32.png) [@paulbutcher](https://www.ruby-forum.com/u/paulbutcher)\
**Post date:** [June 9, 2008, 8:32pm UTC](https://www.ruby-forum.com/t/problem-with-file-upload/139964/3 "2008-06-09T20:32:37Z")

</div>

Ar Chron wrote:

> Is it that params[:image][:file\_name] is just a string, not an object  
> with the method original\_filename?
> 
> What does the rest of the controller code look like in the create? Have  
> you done the @model = Model.new(params[:image]) yet?

Could be. I don’t know. It should be an object. I’ll check.

I’ve done the Model.new. I’ve taken my code from another app where I got  
it working, so it should work. Can it be an issue of permissions, that  
it can’t access the file? Where is the file stored in-between in a file  
upload?
