Simple file upload help


#1

I’m trying to implement the simple file upload example at
http://wiki.rubyonrails.com/rails/pages/HowtoUploadFiles

However, I’m getting an error “No such file or directory” when I
submit the form…

Errno::ENOENT in Admin/websites#create
No such file or directory - /images/websites/websitename.jpg

I believe it’s relating to the code in the model:

def self.save(website)
File.open("/images/websites/#{website[‘name’]}.jpg", “w”) { |f|
f.write(website[‘filename’].read) }
end

From what I understand it is trying to open the file at
/images/websites/websitename.jpg which doesn’t exist. I’m not entirely
sure how this file upload is supposed to work, but essentially I just
want a simple upload that places a file into that location from my
public directory.

Any help would be greatly appreciated,
Paul.