基本的に私がしなければならないことは、データベースに画像を書き込むことです。
imagejpeg関数を理解している限り、「string $ filename」が設定されていないか、NULLの場合、出力はプレーンな画像データである必要があります。しかし、そうではなく、唯一の出力は「1」(真)です。
最初に画像をファイルシステムに保存して再読み込みせずに、画像データを取得するにはどうすればよいですか?
これが私のコード例です:
// 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);