Problem loading images into MySQL

From: Date: Tue, 21 Jan 2003 15:10:33 +0000
Subject: Problem loading images into MySQL
Groups: php.db 
Request: Send a blank email to php-db+get-25011@lists.php.net to get a copy of this message
I'm having big problems getting PHP to load images into a MySQL database. I can and have loaded images perfectly via other routes but when I try to do it via PHP the data always ends up corrupted. I don't get any errors but the binary data is always knackered. I'm using PHP 4.3.0/Apache 2.0.43 on Windows 2000 and MySQL 4.0.7-gamma (also tested with MySQL 3.X) running on a linux box. The upload and post max settings in PHP are both set at 20mb and the size limit to MySQL is also at 20mb. As I said I can load the same files into the database via other routes without problems. The code I'm using is as follows, any ideas what the problem is? session_start(); MYSQL_CONNECT("192.168.1.10","loginname","password") or die('Unable to open database'); mysql_select_db("ImageDB") or die('Unable to select database'); $data = addslashes(fread(fopen($_FILES['UpImg']['tmp_name'], "r"), filesize($_FILES['UpImg']['tmp_name']))); $Qry="INSERT INTO Images (ID,Image,mime,size,OrgName) VALUES (".$_SESSION['SessID'].",\"$data\",\"".$_FILES['UpImg']['type']."\",".$_FILE S['UpImg']['size'].",\"".$_FILES['UpImg']['name']."\")"; $result=MYSQL_QUERY($Qry) or die("<P>DB Write Error<P>".mysql_error());

« previous php.db (#25011) next »