Jump to content


Photo

pictures, in or out of the database


  • Please log in to reply
4 replies to this topic

#1 ThE_eNd

ThE_eNd
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 23 November 2005 - 04:31 PM

Hi.

I'm creating a database that will contain quite a few pictures (700MB - 1GB) and i was wondering how would you recommend handeling them? Should i put them in the database itself or should i use links to them.

I think using links might be a lot easier than putting the pictures in the database but then i'm worried about protecting the pictures.

Any ideas?

#2 ryanlwh

ryanlwh
  • Staff Alumni
  • Advanced Member
  • 511 posts

Posted 23 November 2005 - 06:18 PM

using database to store images would also slow down the backup process. if you worry about protecting the images, you can store them in a directory that is password protected with .htaccess, or in a directory above the web root (above httpdocs, or www, or public_html, etc), then use php file functions and headers to retreive the images.
Please use EDIT * 100...
Please use
or [php] * 1000...

PLEASE READ THE POSTED SOLUTIONS CAREFULLY * 1000000...

#3 ThE_eNd

ThE_eNd
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 23 November 2005 - 07:05 PM

[!--quoteo(post=321482:date=Nov 23 2005, 10:18 AM:name=ryanlwh)--][div class=\'quotetop\']QUOTE(ryanlwh @ Nov 23 2005, 10:18 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
... or in a directory above the web root (above httpdocs, or www, or public_html, etc), then use php file functions and headers to retreive the images.
[/quote]


that sounds interesting, how can i do that?
where do i look for info on how to do that?

if the folders a protected with .htaccess are the pix safe from web spiders and software that downloads entire sites?

#4 ryanlwh

ryanlwh
  • Staff Alumni
  • Advanced Member
  • 511 posts

Posted 23 November 2005 - 10:16 PM

[!--quoteo(post=321501:date=Nov 23 2005, 11:05 AM:name=ThE_eNd)--][div class=\'quotetop\']QUOTE(ThE_eNd @ Nov 23 2005, 11:05 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
that sounds interesting, how can i do that?
where do i look for info on how to do that?

if the folders a protected with .htaccess are the pix safe from web spiders and software that downloads entire sites?
[/quote]

let's say you have these folders under your username:
/username/images
/username/public_html

images would not be accessible directly from the domain. so you'd need a script to be the "middleman".

getImg.php
<?
$path = '/username/images/';
$file = $_GET['file'];
$fileType = 'image/jpeg';

// set the correct header and output the file. make sure no html and echoes are used before this line
header('Content-type: '.$fileType);
echo file_get_contents($path.$file);
?>
as simple as that. now, in your webpages:
<img src='http://www.yourhost.com/getImg.php?file=pic1.jpg'>
that's basically it!
your images are protected from downloading because they have the extention .php. Now you can incorporate the database records into this script to further secure your images. instead of file=pic1.jpg, you could use fileID=10 and fetch the file name and extension from the database.

onto the .htaccess part. web spiders are not able to access the folder. i don't know about site downloading software, but i think they cannot access the folder.
Please use EDIT * 100...
Please use
or [php] * 1000...

PLEASE READ THE POSTED SOLUTIONS CAREFULLY * 1000000...

#5 ThE_eNd

ThE_eNd
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 23 November 2005 - 11:09 PM

thank you so much!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users