私が使用している画像を保存するには:
$image_bin = addslashes(file_get_contents($img_url));
mysql_query('INSERT INTO images
(image_filename, image_type, image_bin)
VALUES
("file.jpg", "image/jpeg", "'.$image_bin.'")');
表示するには:
$qry = 'SELECT image_filename, image_type, image_bin
FROM images
WHERE image_id = 1';
$result = mysql_query($qry);
$row = mysql_fetch_row($result);
header('Content-type: '.$row['image_type']);
echo stripslashes($row['image_bin']);
画像はデータベースに保存されますが、画像サイズが大きくなります。また、画像の色が多少崩れます。
たとえば、開発者ツールを開いた Chrome の画像のスクリーンショット: screensho url
誰が私が間違っているかもしれないことを知っていますか?