Discussion Forums
- Topic List
- Most Recent Posts
- Sign In for more options
can any one help deleting image(which is uploaded to public/profile image folder)rom file.
mohd anas
File.delete(filename, ...) is the function you need.
Try File.delete("#{RAILS_ROOT}/public/profile image folder/#{filename}")
Another trick I am very partial to in Ruby is the ability to run bash commands dynamically. So you could also use backticks like so:
rm #{RAILS_ROOT}/public/profile image folder/#{filename}
Of course this kind of thing will break on Windows, but sorry, Windows isn't a proper development or deployment platform, we have been saying it since people wanted to compile and host MUDs on their Windows boxes.
James, try to use backticks with filename = ' || rm -rf /' ;)
to be platform independent use File.delete and File.join: File.delete( File.join(RAILS_ROOT, 'public', 'profile_image_folder', filename) )
