I have trouble storing .png images with this script. It stores .jpeg images, but not successfully storing .png. Problem is that with .png only half of the picture is stored. The image field in the database is of type blob.
When testing on my local xampp installation it stores lets say 90% of the picture, but when I try it on a hostgator hosted domain it stores lets say 45% of the picture
Don't think it is about the images are larger than the image column in the database as I have stored larger .jpeg images...
static function save($_FILES) {
$link = mysql_connect("localhost",DBUSER,DBPASS) or die("<b>Error:</b><br>".mysql_error());
mysql_select_db(DBNAME,$link) or die("Cant select db");
$tmpName = $_FILES['image']['tmp_name'];
$fp = fopen($tmpName, 'r');
$data = fread($fp, filesize($tmpName));
$data = addslashes($data);
fclose($fp);
$sql = "INSERT INTO image
(type, image, size, name)
VALUES ('" . mysql_real_escape_string($_FILES['image']['type']) . "', '" . $data . "', '" . $_FILES['image']['size'] . "', '" . mysql_real_escape_string($_FILES['image']['name']) . "')";
mysql_query($sql);
}