# File uploading error - No such file or directory

**URL:** <https://www.ruby-forum.com/t/file-uploading-error-no-such-file-or-directory/78980>\
**Category:** Rails\
**Created:** [December 11, 2006, 8:15am UTC](https://www.ruby-forum.com/t/file-uploading-error-no-such-file-or-directory/78980 "2006-12-11T08:15:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vasan\_cec](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/258eb7/32.png) [@vasan\_cec](https://www.ruby-forum.com/u/vasan_cec)\
**Post date:** [December 11, 2006, 8:15am UTC](https://www.ruby-forum.com/t/file-uploading-error-no-such-file-or-directory/78980/1 "2006-12-11T08:15:51Z")

</div>

Hi Everyone,  
Am getting an error while uploading file in application… here  
is the code and the error

Code:-  
File.open("#{RAILS\_ROOT}/images/#{params[:id]}", ‘wb+’) do |f|  
f.write params[:content][:picture].read  
end

Error:-  
Errno::ENOENT in ContentController#update  
No such file or directory - ./images/1

Request Parameters: {“multipart”=\>“true”, “commit”=\>“Update”, “id”=\>“1”,  
“content”=\>{“title”=\>“Test 1”, “startDt(1i)”=\>“2006”,  
“startDt(2i)”=\>“12”, “description”=\>“Test Description 1 a”,  
“startDt(3i)”=\>“3”, “picture”=\>“C:\Documents and Settings\kalyava\My  
Documents\My Pictures\Beautiful Quotations\CA03SREF.jpg”}}

Think the file couldn’t be created for some reason. I searched in google  
but couldn’t get any proper solution. Can anyone guide me?? Am stuck up  
with this for almost 4 days now… ☹

Thanks in advance  
Regards,  
Vasanth

---

<div class="post-metadata">

**Author:** ![vasan\_cec](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/258eb7/32.png) [@vasan\_cec](https://www.ruby-forum.com/u/vasan_cec)\
**Post date:** [December 11, 2006, 9:54am UTC](https://www.ruby-forum.com/t/file-uploading-error-no-such-file-or-directory/78980/2 "2006-12-11T09:54:38Z")

</div>

Vasanthakumar C. wrote:

> Hi Everyone,  
> Am getting an error while uploading file in application… here  
> is the code and the error
> 
> Code:-  
> File.open("#{RAILS\_ROOT}/images/#{params[:id]}", ‘wb+’) do |f|  
> f.write params[:content][:picture].read  
> end
> 
> Error:-  
> Errno::ENOENT in ContentController#update  
> No such file or directory - ./images/1
> 
> Request Parameters: {“multipart”=\>“true”, “commit”=\>“Update”, “id”=\>“1”,  
> “content”=\>{“title”=\>“Test 1”, “startDt(1i)”=\>“2006”,  
> “startDt(2i)”=\>“12”, “description”=\>“Test Description 1 a”,  
> “startDt(3i)”=\>“3”, “picture”=\>“C:\Documents and Settings\kalyava\My  
> Documents\My Pictures\Beautiful Quotations\CA03SREF.jpg”}}
> 
> Think the file couldn’t be created for some reason. I searched in google  
> but couldn’t get any proper solution. Can anyone guide me?? Am stuck up  
> with this for almost 4 days now… ☹
> 
> Thanks in advance  
> Regards,  
> Vasanth

create a folder with name images in your rails directory.i hope it will  
work.

---

<div class="post-metadata">

**Author:** ![vasan\_cec](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/258eb7/32.png) [@vasan\_cec](https://www.ruby-forum.com/u/vasan_cec)\
**Post date:** [December 11, 2006, 11:32am UTC](https://www.ruby-forum.com/t/file-uploading-error-no-such-file-or-directory/78980/3 "2006-12-11T11:32:43Z")

</div>

Yes it worked… but am getting another error now,  
Error:  
NoMethodError in ContentController#update  
undefined method `read’ for #String:0x687f5b8

Any solution to this??
