Dear all.
using this below code i get file name of blob
image = params[:image][:blob]
puts image.methods
image_name = image.original_filename
it gives me
=> rose.jpg
actually i want to append some string with it.how can i do it.pls help.
example => rose_big.jpg
Thanks
--
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
-~----------~----~----~----~------~----~------~--~---
>> string = "rose.jpg"=> "rose.jpg">> modified = string[0..-5] + "_big" + string[-4..-1]=> "rose_big.jpg" you might wannt to check for the "." in that string and cut it there. check out some ruby basics for string manipulation. --~--~---------~--~----~------------~-------~--~----~ 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 Tue, Feb 17, 2009 at 4:42 AM, Newb Newb <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Dear all. > using this below code i get file name of blob > image = params[:image][:blob] > puts image.methods > image_name = image.original_filename > it gives me > => rose.jpg > actually i want to append some string with it.how can i do it.pls help. > example => rose_big.jpg >Hi, here''s another option using the File class: filename = File.basename( filename, ".jpg" ) + "_what_ever_you_want + File.basename( filename ) Good luck, -Conrad> > Thanks > -- > 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 -~----------~----~----~----~------~----~------~--~---