I am using PHP 5.3.5 and postgreSQL. I am storing and extracting images from database.
For storing i am doing this:
$escaped_data = base64_encode(file_get_contents($_FILES['fileUpload']['tmp_name']));
$fileModel->setBinary_Data($escaped_data);
It's working, i received the image in my database (Bytea field).
The problem is to extract this, i am trying this code to extract my images:
$file_info = $fileModel->getBinary_Data($id_file); // This function return the binary_data of the image
header('Content-Type: image/jpeg;base64');
header('Content-Disposition: attachment; filename=' . $file_info['_name']);
base64_decode($file_info['binary_data']));
When i download the image, i can't see the image...
With echo in:
echo base64_decode($file_info['binary_data']);
This happen:
http://imageshack.us/f/18/encodez.jpg/
After, i am trying using the function stream_get_contents inside base64_decode, but doens't work.
Someone know how i can download my images with php?
Thanks anyway...