Hi, i have made a file uploading function on my application, the thing is i want to allow my users to download the file (can be pdf, doc, img, etc) so in my file upload controller: def download @photo = Photo.find(params[:id]) send_file("#{RAILS_ROOT}/public/"+@photo.filename, :filename => @photo.filename, :type => @photo.content_type, :disposition => ''attachment'') end this works perfectly fine, BUT only if the file actually exists in ../public/.. i noticed that when i try to upload a file using the app, it doesn''t automatically store it into the public folder. if i manually copy paste the file into the public folder, the download works fine. this is my controller, (notice that the new & create methods doesn''t say anything about storing the uploaded files into the public folder) class PhotoAdminController < ApplicationController def index list render :action => ''list'' end # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html) verify :method => :post, :only => [ :destroy, :create, :update ], :redirect_to => { :action => :list } def list @photo_pages, @photos = paginate :photos, :per_page => 10 end def show @photo = Photo.find(params[:id]) end def new @photo = Photo.new end def create @photo = Photo.new(params[:photo]) if @photo.save flash[:notice] = ''Photo was successfully created.'' redirect_to :action => ''list'' else render :action => ''new'' end end def edit @photo = Photo.find(params[:id]) end def update @photo = Photo.find(params[:id]) if @photo.update_attributes(params[:photo]) flash[:notice] = ''Photo was successfully updated.'' redirect_to :action => ''show'', :id => @photo else render :action => ''edit'' end end def destroy Photo.find(params[:id]).destroy redirect_to :action => ''list'' end def download @photo = Photo.find(params[:id]) send_file("#{RAILS_ROOT}/public/images/"+@photo.filename, :filename => @photo.filename, :type => @photo.content_type, :disposition => ''attachment'') end end can someone teach me how to code my app to store the uploaded file into the public folder? thank you very much in advance! -- 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 -~----------~----~----~----~------~----~------~--~---
On Jan 15, 5:48 pm, Jojo Mojo <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> can someone teach me how to code my app to store the uploaded file into > the public folder?I suggest you use the attachment_fu plugin. It works very well and will give you the option of storing your files in the database, file system or using Amazon S3. You could certainly write similar code yourself, but why re-invent the wheel? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Aaron Chase wrote:> On Jan 15, 5:48 pm, Jojo Mojo <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > wrote: > >> can someone teach me how to code my app to store the uploaded file into >> the public folder? > > I suggest you use the attachment_fu plugin. It works very well and > will give you the option of storing your files in the database, file > system or using Amazon S3. You could certainly write similar code > yourself, but why re-invent the wheel?i''ve looked through the attachment_fu plugin, but i didn''t seem to see any where that states storing files in the database -- 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 -~----------~----~----~----~------~----~------~--~---
On Jan 15, 9:40 pm, Jojo Mojo <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> i''ve looked through the attachment_fu plugin, but i didn''t seem to see > any where that states storing files in the databaseRead the section called ''attachment_fu migrations'' in this document: http://svn.techno-weenie.net/projects/plugins/attachment_fu/README. DB storage is the default, although you probably want to store images in the file system instread. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Aaron Chase wrote:> On Jan 15, 9:40 pm, Jojo Mojo <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > wrote: >> i''ve looked through the attachment_fu plugin, but i didn''t seem to see >> any where that states storing files in the database > > Read the section called ''attachment_fu migrations'' in this document: > http://svn.techno-weenie.net/projects/plugins/attachment_fu/README. > DB storage is the default, although you probably want to store images > in the file system instread.oh i see it now! :) thanks guys! -- 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 -~----------~----~----~----~------~----~------~--~---