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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux