Hi Team, I have create one ruby on rails application ,i have one issue for that image upload ,the image will override the some user , so any can solve the issues ************************ contoller class PhotosController < ApplicationController # GET /photos # GET /photos.xml def index @photos = Photo.all respond_to do |format| format.html # index.html.erb format.xml { render :xml => @photos } end end # GET /photos/1 # GET /photos/1.xml def show @photo = Photo.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @photo } end end # GET /photos/new # GET /photos/new.xml def new @photo = Photo.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @photo } end end # GET /photos/1/edit def edit @photo = Photo.find(params[:id]) end # POST /photos # POST /photos.xml def create @photo = Photo.new(params[:photo]) respond_to do |format| if @photo.save format.html { redirect_to(@photo, :notice => ''Photo was successfully created.'') } format.xml { render :xml => @photo, :status => :created, :location => @photo } else format.html { render :action => "new" } format.xml { render :xml => @photo.errors, :status => :unprocessable_entity } end end end # PUT /photos/1 # PUT /photos/1.xml def update @photo = Photo.find(params[:id]) respond_to do |format| if @photo.update_attributes(params[:photo]) format.html { redirect_to(@photo, :notice => ''Photo was successfully updated.'') } format.xml { head :ok } else format.html { render :action => "edit" } format.xml { render :xml => @photo.errors, :status => :unprocessable_entity } end end end # DELETE /photos/1 # DELETE /photos/1.xml def destroy @photo = Photo.find(params[:id]) @photo.destroy respond_to do |format| format.html { redirect_to(photos_url) } format.xml { head :ok } end end end ******************************** class Photo < ActiveRecord::Base # Root directory of the photo public/photos PHOTO_STORE = File.join RAILS_ROOT, ''public'', ''images'' # Invoke save_photo method when save is completed after_save :save_photo def load_photo_file=(data) # Record the filename self.filename = data.original_filename # Store the data for later use @photo_data = data end name = File.join PHOTO_STORE, self.filename File.open(name, ''wb'') do |f| f.write(@photo_data.read) end @photo_data = nil end end end def fileexist if FileTest.exists?(RAILS_ROOT + "public/images/#{@photo_data}") render :text => "yes" else render :text => "no " end end ************************ <table> <tr> <th>Filename</th> </tr> <% @photos.each do |photo| %> <tr> <td><%=h photo.filename %></td> <td><%= image_tag photo.filename%></td> <td><%= link_to ''Show'', photo %></td> <td><%= link_to ''Edit'', edit_photo_path(photo) %></td> <td><%= link_to ''Destroy'', photo, :confirm => ''Are you sure?'', :method => :delete %></td> </tr> <% end %> </table> <br /> <%= link_to ''New '', new_photo_path %> -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
> ...the image will override the some user...Maybe its just me but I have a problem understanding what you mean with that sentence. If you can''t describe your problem clearly I doubt you''ll get an answer. I have some apps where I take care of uploads myself but why aren''t you using some of the upload gems available? Like paperclip or carrierwave for example? They do save work. https://github.com/thoughtbot/paperclip https://github.com/jnicklas/carrierwave Cheers. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
HI sir, I have working ruby on rails and i can upload multiple image upload without plugin in ror , 1.I am using session and create user folder in local system 2. I can upload the one image 3.i can upload multiple image its override the image(user) pls give some idea -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
john paul wrote in post #1019004:> HI sir, > > > I have working ruby on rails and i can upload multiple image upload > without > plugin in ror , > > 1.I am using session and create user folder in local system > 2. I can upload the one image > 3.i can upload multiple image its override the image(user) > pls give some ideaUsing session folder, the local system multiple idea override. Then system the local folder in the session upload. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Sir, Actually the was uploaded ,in user folder I need multiple image uploaded means the was override , my question is image don''t override the image is multiple images display -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
john paul wrote in post #1019013:> Sir, > Actually the was uploaded ,in user folder > > > I need multiple image uploaded means the was override , > > my question is image don''t override the image is multiple images displayTake the and put it in the images question load. Then override the local system user. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Possibly Parallel Threads
- rmagick and imagemagick
- Carrierwave Direct and additional form elements
- Unable to find the image path via file system using the paperclip plugin through the get method
- Help Regarding Amazon S3 and Career Wave along with Rspec
- Rails 2.3.11 and carrierwave, can't find generator