Hello, I try to prepare a upload page and here''s my controller: def new if request.post? begin @file = params[:img] if @file.original_filename.length > 0 filename = "/images/userimg/" + @file.original_filename File.open(filename, "wb") { |f| f.write(@file.read) } end end end end I want the file to be saved into the public/images/userimg folder. but i get error at runtime: "No such file or directory - /images/userimg/arrowd.gif" what can i do for it? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Bahadır Doğan wrote:> I want the file to be saved into the public/images/userimg folder. but i > get error at runtime: "No such file or directory - > /images/userimg/arrowd.gif" > > what can i do for it?You check if you have folder /images/userimg :) -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I have it: "public/images/userimg" Do I need to get the real path of that folder? Jamal Soueidan wrote:> Bahadır Doğan wrote: >> I want the file to be saved into the public/images/userimg folder. but i >> get error at runtime: "No such file or directory - >> /images/userimg/arrowd.gif" >> >> what can i do for it? > > You check if you have folder /images/userimg :)-- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Jul 26, 3:11 am, "Bahadır Doğan" <rails-mailing-l...@andreas-s.net> wrote:> I have it: "public/images/userimg" > > Do I need to get the real path of that folder?Try: filename = "#{RAILS_ROOT}/public/images/userimg/" + @file.original_filename Be aware that this could be abused. It might be possible for someone to put ../ in the filename and do something malicious like add a controller to your application or overwrite your log files. ~Rusty --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
yes,that''s right: filename = "#{RAILS_ROOT}/public/images/userimg/" + -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---