Loomy Posted December 13, 2006 Share Posted December 13, 2006 I'm using MySQL to store a bunch of images (BLOB fields). Putting them in is (I think), but when I'm trying to view any of the images again the colors (on JPEG images) is completely wrong and there's a lot of corruption - the image is beyond recognition. On PNG images there's simply a message saying the image contains errors and can not be displayed.Here's the relevant parts of the code:[code]<?php// Get data from upload form then insert the image to DB$file_contents = addslashes(file_get_contents($file['tmp_name']));//...$query = "INSERT INTO `multimedia` (`data`) VALUES('$data')";// Get image from DB and display itheader("Content-type: image/jpeg");// $imgData = image data SELECTed from DBecho stripslashes($imgData);?>[/code](ignore the fact that there are several different variable names - this code is split among a few files)Does anyone spot any errors, og have any idea what the cause may be? Could database charset, file charset and that sort of thing have anything to do with this?[b]UPDATE[/b]I solved it by removing stripslashes() - I have no idea why, but as long as it's working... :) Link to comment https://forums.phpfreaks.com/topic/30556-solved-image-stored-in-mysql-corrupted-when-viewing/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.