Reputation: 58810
I am 100% sure that I have a file on that path.
I'm trying to convert my logo.png to base64
$imagedata = file_get_contents("/images/account/operator/logo.png");
$base64 = base64_encode($imagedata);
I kept getting
file_get_contents(/images/account/operator/logo.png): failed to open stream: No such file or directory
Upvotes: 0
Views: 97
Reputation: 11689
You have to use the absolute path:
$_SERVER['DOCUMENT_ROOT']. '/images/account/operator/logo.png'
Upvotes: 1
Reputation: 1342
You're using the absolute path. Unless there's an /images dir in your root folder on the server, file_get_contents()
won't be able to access it. Modify your path to the image to use the correct value.
Upvotes: 2