tags:

views:

17

answers:

1

Can you please guide me how can I convert an image from a URL to base64 encoding?

thanks

+3  A: 

Easy:

$imagedata = file_get_contents("/path/to/image.jpg");
             // alternatively specify an URL, if PHP settings allow
$base64 = base64_encode($imagedata);

bear in mind that this will enlarge the data by 33%, and you'll have problems with files whose size exceed your memory_limit.

Pekka