I am attempting to write to an image file from a blob.
if($_POST[\'logoFilename\'] != \'undefined\'){
$logoFile = fopen($_POST[\'logoFilename\'], \'w\') o
Your "Blob" is really a Data URI:
data:[][;charset=][;base64],
Since you only want the decoded data part, you have to do
file_put_contents(
'image.jpg',
base64_decode(
str_replace('data:image/jpeg;base64,', '', $blob)
)
);
But since PHP natively supports data:// streams, you can also do (thanks @NikiC)
file_put_contents('image.jpg', file_get_contents($blob));
If the above doesnt work, you can try with GDlib:
imagejpg(
imagecreatefromstring(
base64_decode(
str_replace('data:image/jpeg;base64,', '', $blob)
)
),
'image.jpg'
);