Hi everybody,
I need to store images over a standard html form into a mysql-table MEDIUMBLOB-Field.
Getting the file works :
$file = mysql_real_escape_string(file_get_contents("php://input"));
At this point, I can just write $file into a new file:
fwrite(fopen('dir', 'w'), $filet);
This works, so I conclude that uploading the file into a string works.
Now I want to put $file into the DB, therefore I use a simple INSERT-Statement, nothing special with that.
In a next step, I read (SELECT...) the $file out of the DB and write it to a file:
$fh = fopen('dir/filename', "w");
fwrite($fh, ($file[data]));
fclose($fh);
The problem: the written file is
a) ~ 4x as big as the input file (compression ?!)
b) not readable. ("Missing MetaTags if I try to open the image with gwenview).
What am I doing wrong? May mysql_real_escape_string trigger this behaviour?
Thanks for your advices, I'm stucked..
🙂