Surekha Matte
2006-May-04 07:27 UTC
[Rails] How to upload only jpeg & gif & png images into public/images using rubyonrails
Hello iam new to rubyonrails. Please any one help me out in "How to upload only jpeg & gif & png images into public/images using rubyonrails" Thanks in Advance -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060504/33a17ad2/attachment.html
Enrico Teotti
2006-May-04 07:37 UTC
[Rails] How to upload only jpeg & gif & png images into public/images using rubyonrails
hi there, I hate when people send me an URL instead of an answer but I think you should read this one: :-) http://wiki.rubyonrails.com/rails/pages/HowtoUploadFiles to check the file type the example talks about person[''picture''].content_type I''ve never tried it BTW, HTH! Enrico 2006/5/4, Surekha Matte <ieg.surekha.matte@gmail.com>:> Hello iam new to rubyonrails. Please any one help me out in "How to upload > only jpeg & gif & png images into public/images using rubyonrails" > > Thanks in Advance > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >-- "The only thing necessary for the triumph of evil is for good men to do nothing" Edmund Burke
Surekha Matte
2006-May-04 08:03 UTC
[Rails] How to upload only jpeg & gif & png images into public/images using rubyonrails
Already I go thru this link, I implemented in my application. The images are uploaded but those are not as the original images. Overlapped with some colours. But one image is uploaded successfully its size is 977Bytes. If it is 2, or 1.4 KB or more than this not uploaded as original images so plz help me out in this thing On 5/4/06, Enrico Teotti <agenteo@gmail.com> wrote:> > hi there, > I hate when people send me an URL instead of an answer but I think you > should read this one: :-) > http://wiki.rubyonrails.com/rails/pages/HowtoUploadFiles > to check the file type the example talks about > person[''picture''].content_type > I''ve never tried it BTW, > HTH! > Enrico > > 2006/5/4, Surekha Matte <ieg.surekha.matte@gmail.com>: > > Hello iam new to rubyonrails. Please any one help me out in "How to > upload > > only jpeg & gif & png images into public/images using rubyonrails" > > > > Thanks in Advance > > > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > > > -- > "The only thing necessary for the triumph of evil > is for good men to do nothing" > Edmund Burke > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060504/30d7bda1/attachment-0001.html
Jon Mr
2006-May-10 21:53 UTC
[Rails] Re: How to upload only jpeg & gif & png images into public/i
Surekha Matte wrote:> Already I go thru this link, I implemented in my application. The images > are > uploaded but those are not as the original images. Overlapped with some > colours. But one image is uploaded successfully its size is 977Bytes. > If it is 2, or 1.4 KB or more than this not uploaded as original images > > so plz help me out in this thingMake sure that in your database table you have the data column set to ''longblob'' not just blob. it will crop the image if you don''t! jon -- Posted via http://www.ruby-forum.com/.
Dorian
2006-May-12 12:47 UTC
[Rails] Re: How to upload only jpeg & gif & png images into public/i
Well, It looks like no one intends to help you, which is pretty much the experience that Ive had on this mailing list. So heres some of my code. This is in my pcomic_admin controller that allows editors for my magazine to submit comics. The code is not finished yet. It doesnt check for errors in alot of places that it should. It also does not check the file size. Im also wary of allowing uploads to the public directory. Im thinking that the image should actually go into a sub folder with black hole permissions, similar to an ftp setup. Maybe others on this list can give an opinion, that would be nice for once. Dorian def create if @session[''user''].nil? redirect_to :action => ''login'' elsif params[:comicpic].content_type.chomp == "image/jpeg" @user = User.find(@session[''user''].id) File.open("../public/comics/#{@user.id}/#{params[:comicpic].original_filename}", "w") do |f| f.write(params[:comicpic].read) end @comic = Pendingcomic.new(params[:comic]) @comic[''image_url''] = "/comics/#{@user.id}/#{params[:comicpic].original_filename}" @user.pendingcomics.push(@comic) redirect_to :action => ''list'' else redirect_to :action => ''list'' end end Surekha Matte wrote:> Hello iam new to rubyonrails. Please any one help me out in "How to > upload > only jpeg & gif & png images into public/images using rubyonrails" > > Thanks in Advance-- Posted via http://www.ruby-forum.com/.
szymek
2006-May-12 13:15 UTC
[Rails] Re: How to upload only jpeg & gif & png images into public/i
You could also use file_column plugin: http://www.kanthak.net/opensource/file_column/ You can install the latest revision like this: script/plugin install http://opensvn.csie.org/rails_file_column/plugins/file_column/trunk Then if you want you can generate docs for this plugin: rake doc:plugins Now if you want to allow uploading of specific formats you can do: class Entry < ActiveRecord::Base file_column :image validates_file_format_of :field, :in => ["gif", "png", "jpg"] end And that''s all. Really simple. -- Posted via http://www.ruby-forum.com/.