Hi all, I''ve done a good 8+ hours of searching for a good solution to my problem but have had little success finding a nice and easy image upload solution. Oh, and I am new to rails. My problem/requirement is that I want to upload an image to the file system (not the database) as quickly and efficiently as possible. I currently do not want any resizing or ajax functionality (so no fleximage/swfupload), just a plain <%= f.file_field :image %> to allow me access to select the image and upload it to the /public/images/users folder. There must be a very easy way to do this in rails. I have noticed that there are a lot of people uploading directly into the database. Is this a better way? It seems to me that the database should be strictly for data. Thanks in advance and I apologize for the novice questions! Best regards, Tony -- 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 -~----------~----~----~----~------~----~------~--~---
Hello I do this on the filesystem with: (params[:photo] is posted) file_name = "something" File.open("#{RAILS_ROOT}/public/writable/submissions/" << @user.path << "/tmp/" << file_name, "w"){ |f| f.write(params[:photo].read)} # and for resize.. image = Magick::Image.read("#{RAILS_ROOT}/public/writable/submissions/" << @user.path << "/tmp/" << file_name).first if !image.nil? @type = image.format @geometry = image.columns.to_s + "x" + image.rows.to_s @imgcol = image.image_type long_side = (image.columns > image.rows) ? image.columns : image.rows im = image.change_geometry!(tn) { |cols, rows, img| img.resize!(cols, rows) } im.write("#{RAILS_ROOT}/public/writable/submissions/" << @user.path << "/thumb/" << file_name) end On Sun, May 25, 2008 at 6:20 PM, Tony Tony <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> There must be a very easy way to do this in rails. I have noticed that > there are a lot of people uploading directly into the database. Is this > a better way? It seems to me that the database should be strictly for > data.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Did you check out paperclip, http://giantrobots.thoughtbot.com/2008/5/15/paperclip-tips-and-updates, or attachment_fu, http://clarkware.com/cgi/blosxom/2007/02/24. You don''t need to use the resizing features and both allow saving to the file system. You also don''t want to upload directly to the database. Use the db just to store meta-data about the image. best. mike On May 25, 12:20 pm, Tony Tony <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hi all, > > I''ve done a good 8+ hours of searching for a good solution to my problem > but have had little success finding a nice and easy image upload > solution. Oh, and I am new to rails. > > My problem/requirement is that I want to upload an image to the file > system (not the database) as quickly and efficiently as possible. I > currently do not want any resizing or ajax functionality (so no > fleximage/swfupload), just a plain <%= f.file_field :image %> to allow > me access to select the image and upload it to the /public/images/users > folder. > > There must be a very easy way to do this in rails. I have noticed that > there are a lot of people uploading directly into the database. Is this > a better way? It seems to me that the database should be strictly for > data. > > Thanks in advance and I apologize for the novice questions! > > Best regards, > Tony > -- > Posted viahttp://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 -~----------~----~----~----~------~----~------~--~---