views:

521

answers:

1

I need to use this in my rails program so I can get the image contents and then base64 it. I know how to base64 it but I just don't know how I would get the image. Anyone know how?

+2  A: 

Edited to retrieve from external URL:

PHP:

$image = file_get_contents("http://www.site.com/file.png");

Ruby:

require 'net/http'
image = Net::HTTP.get_response(URI.parse("http://www.site.com/file.png")).body
jimyi
Awesome, you are amazing. Thank you VERRYYY much.
deuces