I am attempting to write to an image file from a blob.
if($_POST['logoFilename'] != 'undefined'){
$logoFile = fopen($_POST['logoFilename'], 'w') or die ("Cannot create ".$_POST['logoFilename']);
fwrite($logoFile, $_POST['logoImage']);
fclose($logoFile);
}
In the previous code snippet, $_POST['logoImage']
is a BLOB. The file is correctly written to the root directory, however the file cannot be opened. In ubuntu 11.04 I receive the following error:
Error interpreting JPEG image file (Not a JPEG file: starts with 0x64 0x61).
The BLOB does correctly display if I create an img and set its src=blob
Included below is the first snippet of the BLOB:
data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEBLAEsAAD/2wBDAAgGBgcGBQgHBwcJCQ