Reputation: 25
I want to create an image in php having the data encoded in base64
Use the code: file_put_contents('export/MyFile.png', base64_decode($img));
I read on the browser, but 7483 should be a larger number.
if I open the image was created only half (the other half is transparent)
if the variable $img contains a short string, it works.
if it contains a string too long the image will be created only partially.
why?
PS: if I use
$img = base64_decode($img);
$fp = fopen("export/MyFile.png", "w");
fwrite($fp, $img);
fclose($fp);
I have the exact same problems
thanks
Upvotes: 0
Views: 638
Reputation: 4670
file_put_contents('export/MyFile.png', base64_decode($img));
Should be:
file_put_contents('export/MyFile.png', base64_encode($img));
If you want to encode the image, you can't use the decode function.
Upvotes: 1