Evening all! I''ve decided to give it another shot with the image upload functionality provided with the tutorial ''RailsSpace''... I''ve got further, in the fact that it recognizes an upload attempt, but fails with the message: File upload failed. Try a different image? I used a small-ish sized file (28k) The max upload size is 1mb as seen within the def valid_file? action: if @image.size > 1.megabyte errors.add(:image, "can''t be bigger than 1 megabyte") return false The error message I''m now getting is based within the ''successful_conversion? action: def successful_conversion? # Prepare the filenames for the conversion. source = File.join("tmp", "#{@user.username}_full_size") full_size = File.join(DIRECTORY, filename) thumbnail = File.join(DIRECTORY, thumbnail_name) # Ensure that small and large images both work by writing to a normal file. # (Small files show up as StringIO, larger ones as Tempfiles.) File.open(source, "wb") { |f| f.write(@image.read) } # Convert the files. img = system("#{convert} #{source} -resize #{IMG_SIZE} # {full_size}") thumb = system("#{convert} #{source} -resize #{THUMB_SIZE} # {thumbnail}") File.delete(source) if File.exists?(source) # Both conversions must succeed, else it''s an error. unless img and thumb errors.add_to_base("File upload failed. Try a different image?") return false end return true end However - i dont understand why this hasn''t uploaded... Anyone else had this problem??? Thanks a lot for reading!
On Nov 3, 9:29 pm, RubyonRails_newbie <craigwest...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> > However - i dont understand why this hasn''t uploaded... > > Anyone else had this problem???Have you tried stepping through the code and seeing at which point this fails? Fred> > Thanks a lot for reading!
Yeah - Although i''m new to this, I guessed its got up to the point where it checks directories, and converts the image into a thumb. If it hasn''t converted them, it throws the error. Thats how i read it. If that''s wrong, fair enough, but I''m not sure how exactly to resolve this.... On 3 Nov, 21:37, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Nov 3, 9:29 pm, RubyonRails_newbie <craigwest...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> > wrote: > > > > > However - i dont understand why this hasn''t uploaded... > > > Anyone else had this problem??? > > Have you tried stepping through the code and seeing at which point > this fails? > > Fred > > > > > > > Thanks a lot for reading!
SUCCESS!!!! WOOOO!!! :-) It turns out my convert is stored in "/usr/local/bin/convert" however the action in the tutorial sets it as: usr/bin/convert. Avatar is now uploaded. Thanks for the response though!!! On 3 Nov, 21:44, RubyonRails_newbie <craigwest...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> Yeah - Although i''m new to this, I guessed its got up to the point > where it checks directories, and converts the image into a thumb. > > If it hasn''t converted them, it throws the error. > > Thats how i read it. If that''s wrong, fair enough, but I''m not sure > how exactly to resolve this.... > > On 3 Nov, 21:37, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > On Nov 3, 9:29 pm, RubyonRails_newbie <craigwest...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> > > wrote: > > > > However - i dont understand why this hasn''t uploaded... > > > > Anyone else had this problem??? > > > Have you tried stepping through the code and seeing at which point > > this fails? > > > Fred > > > > Thanks a lot for reading!