Basically what I have to do, is write a Image to the database.
As far as I understand the imagejpeg function – the output should be the plain image data, if the “string $filename” is not set or NULL.
But it does not, the only output is “1” (true)…
How do I get to the image data, without first storing the image in the filesystem and reloading it?
Here is my Code example:
// If it is the right filetype.
if ($_FILES[$dom_element]['type'] == 'image/jpeg' || $_FILES[$dom_element]['type'] == 'image/pjpeg') {
// Create the image recource.
$image_image = imagecreatefromjpeg($_FILES[$dom_element]['tmp_name']);
}
// Resize the image.
imagecopyresampled($image_image_p, $image_image, 0, 0, 0, 0, $image_new_width, $image_new_height, $image_width, $image_height);
// Write the image in the database (does not work this way -> output = "1")
mysql_select_db("$db_announcement");
$sql = "UPDATE announcement
SET announcement_guest_image_data = '" . addslashes(imagejpeg($image_image_p, NULL, $settings_image_quality)) . "',
announcement_guest_image_exists = 'yes'
WHERE announcement_timestamp = '$timestamp' AND announcement_guest_mail = '$global_mail'";
$sql = mysql_query($sql);
// Delete the image recources.
imagedestroy($image_image);
imagedestroy($image_image_p);
The documentation says about the
$filenameparameter:And about the return value:
The function outputs the image to the standard output. It does not
returnit.You can capture it from the standard output like so: