File uploading error - No such file or directory

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… :frowning:

Thanks in advance
Regards,
Vasanth

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… :frowning:

Thanks in advance
Regards,
Vasanth

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

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

Any solution to this??