RE: [PHP] file from database work local, but not on server

From: Date: Thu, 08 Jun 2006 11:22:32 +0000
Subject: RE: [PHP] file from database work local, but not on server
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-237640@lists.php.net to get a copy of this message
Hi Tedd, Thank you for your answer. I have it working for images already, the problem comes to Excel, PDF's etc. I will do some more testing using your sample, thanks. /Peter -----Original Message----- From: tedd [mailto:tedd@sperling.com] Sent: Thursday, June 08, 2006 9:29 PM To: Peter Lauri; 'Chris' Cc: php-general@lists.php.net Subject: RE: [PHP] file from database work local, but not on server At 9:03 AM +0700 6/8/06, Peter Lauri wrote: >Is there anyone with reference of a small example of binary storage and >retrieval from database? I have performed working solutions for images >before, but this should support any file extensions (with exceptions of >course). Peter: Storage and retrieval of an image in a dB is the same as any other data *. The problem I imagine you are having is how to prepare the data for insertion into the dB and how to display the data after you pull it back out. To prepare for insertion, try this: $image = addslashes(file_get_contents($_FILES['userfile']['tmp_name'])); (I have magic_quotes set to OFF -- if you have it ON, remove the addslashes().) To prepare the image file for display after retrieval, try this: ob_start(); ... your dB retrieval code $fileContent = mysql_result($result, 0, "image"); $image = imagecreatefromstring($fileContent); imagejpeg($image, null, 100); ob_end_flush(); --- hth's tedd *<please gang -- no holy war about storing images in a dB> -- ---------------------------------------------------------------------------- -------- http://sperling.com http://ancientstones.com http://earthstones.com

« previous php.general (#237640) next »