Re: problem with storing & displaying image in db
| From: | Steve Lawson | Date: | Sun, 22 Apr 2001 21:29:46 +0000 |
| Subject: | Re: problem with storing & displaying image in db | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-49764@lists.php.net to get a copy of this message | ||
Why not just store the filename?
SL.
----- Original Message -----
From: "Keyur Kalaria" <keyur@hyper-net.net>
To: "php" <php-general@lists.php.net>
Sent: Saturday, April 21, 2001 9:52 AM
Subject: [PHP] problem with storing & displaying image in db
> Hello everybody,
>
> I am facing a strange problem while uploading and displaying images in a
> database table.
>
> I have taken blob field to store the images.
>
> Images which are less then around 100kb are stored & displayed properly
but
> images which are greater than 100kb are giving problems while displaying
> although no errors were generated while inserting them in database.
>
> what could be the problem ? is it due to the blob type ?
>
> i am using the following statements to insert the file to database.
>
> insert.php
> ***********************************
> $imgsize=GetImageSize($photofile);
> $photo=addslashes(fread(fopen($photofile, "r"), filesize($photofile)));
> $query="insert into photo(photoformat,photo,photowidth,photoheight) values
> ('$photoformat','$photo',$imgsize[0],$imgsize[1])";
>
> $photoformat, $photofile are the input fields of the form which is
> submitted.
>
> ***********************************
>
> in my html pages i use the following <img> :
>
> <img src=display.php?id=1>
>
> and my display.php is as follows:
>
> display.php
> ***********************************
> $query="select * from photo where id='$id'";
> $result=mysql_query($query);
> $photo_rec=mysql_fetch_array($result);
> Header( "Content-type: image/$photo_rec[photoformat]; name=".microtime());
> echo $photo_rec["photo"];
>
> ***********************************
>
>
> Thanks in advance
>
> Keyur
> $$$$$$$
>
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>