1
I need to save a jpg image in the database in a BLOB column, however, everything I tried didn’t work out, what I’m testing now to try to generate the byte array is this:
ini_set('memory_limit', '-1');
$filename = $file['tmp_name'];
$byteArrayFile = "";
$fhandle = fopen($filename, "rb");
while (!feof($fhandle)) {
$data = fread($fhandle, 1);
// array_push($byteArrayFile, $data);
$byteArrayFile .= $data;
}
fclose($fhandle);
And to insert in the comic I’m trying something like this:
$sql = "INSERT INTO TABELA(campo_blob) VALUES('{$byteArrayFile}')";
But as I wrote at the beginning, nothing went right, someone knows the right way to save the image in the BLOB column comic ?
Thank you.
Behold
– durtto
It would be good to say which is the BD used. Of qq way, read byte to byte file is terrible, and work with memory_limit so is Gambi. Anyway, this reading you are doing has one of the answers of the original indicated in the close, take a look at them. If your case is different from that, edit the question with relevant details and leave a comment.
– Bacco
The BD is Mysql, but the answer to the question already exists and solved my problem! (http://answall.com/questions/42886/salvar-no-banco-data_count%C3%Bado-bin%C3%A1rio-de-uma-imagem) Thank you!
– user2831852