I'm not any kind of expert on this, but you just read the file byte for byte, dont you? So it should be the same amount of data.
On Thu, 30 Sep 2004 15:51:28 -0400, GH <[EMAIL PROTECTED]> wrote: > HEre is a question that I have been wondering about: > > - Does the image file use more space in the db or as a file itself > (Do Not count the extra data that one would store in the db along with > the image... ie. ID number) > > Thanks > > > > > On Thu, 30 Sep 2004 09:55:30 -0700, Jasper Howard <[EMAIL PROTECTED]> wrote: > > If you're uploading a file then you can make a script that reads the > > temp file into the database (otherwise you need to muck around with > > image functions and I'm not the one to ask about that), something > > like: > > > > $image = mysql_escape_string(fread(fopen($_FILES['file']['tmp_name'], > > "r"), filesize($_FILES['file']['tmp_name']))); > > > > Then you just put $image in the db under a BLOG field type. This is > > what I did when I needed to save some images to a db and it seemed to > > work fine. Make sure you save the file type to the database so you can > > display the image properly. When you are ready to display an image, > > just create the html for an image and set the source to a php script > > that will output the image: > > > > <img src="scripts/display_image.php?id=1"> > > > > And in the display_image.php script do something like this: > > > > <? > > ...DB QUERY... > > > > $type = $row['file_type']; > > $dfile = $row['file_data']; > > header("Content-Type: $type"); > > header("Content-Disposition: filename=".basename($dfile).";"); > > header("Content-Length: ".filesize($dfile)); > > readfile("$dfile"); > > exit; > > ?> > > > > That code was modified a bit from its origional function (forcing > > download of the file) but I think it should just work, but there's > > always the chance I messed it up somehow. > > > > hope that works for someone, > > -Jasper Howard > > > > > > > > > > On Mon, 27 Sep 2004 19:05:16 -0500, Jim Grill <[EMAIL PROTECTED]> wrote: > > > > 1) there is no need to fiddle with directory permissions to write images. > > > > 2) if the content is sensitive you have the added security of the database > > > > password (and the fact that the database is ususally not directly > > > > accessible). > > > > 3) a mysqldump gives a backup of all images along with other persistent > > > data > > > > > > > > Other disadvantages follow: > > > > 1) excessive load on the server for loading each image > > > > 2) the load mentioned above causes a slow down in the script > > > > 3) images usually need to be written to file before using GD for > > > > manipulation, inclusion in PDFs, etc. > > > > > > > That's a very good list. > > > > > > I just wanted to pipe in on this one thing: > > > > > > "3) images usually need to be written to file before using GD for > > > manipulation, inclusion in PDFs, etc." > > > > > > There is actually a function for this: imagecreatefromstring() > > > > > > I'll don't want to touch the rest of this topic though. :-) > > > > > > Jim Grill > > > > > > > > > > > > -- > > > PHP General Mailing List (http://www.php.net/) > > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > > > > > > -- > > <<-------------------------------------------------------- > > Jasper Howard - Database Administration > > ApexEleven.com > > 530 559 0107 > > ------------------------------------------------------->> > > > > > > > > -- > > > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > -- <<-------------------------------------------------------- Jasper Howard - Database Administration ApexEleven.com 530 559 0107 ------------------------------------------------------->> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php