3 Replies - 332 Views - Last Post: 16 July 2011 - 01:29 AM Rate Topic: -----

#1 E_Geek  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 45
  • View blog
  • Posts: 236
  • Joined: 20-February 11

Storing Images

Posted 15 July 2011 - 12:58 PM

Hey,

Am I correct in thinking storing images in the file system and adding a database pointer is faster than saving the image as a BLOB within a database?

If yes, for a pointer, would I just use the filename (E.g '/Images/myImage.jpg' as string), or is their some other intricate method I should be using?

Thank you :)

Is This A Good Question/Topic? 0
  • +

Replies To: Storing Images

#2 Ace26  Icon User is offline

  • D.I.C Head

Reputation: 40
  • View blog
  • Posts: 179
  • Joined: 10-August 08

Re: Storing Images

Posted 15 July 2011 - 02:51 PM

View PostE_Geek, on 15 July 2011 - 09:58 PM, said:

Hey,

Am I correct in thinking storing images in the file system and adding a database pointer is faster than saving the image as a BLOB within a database?

If yes, for a pointer, would I just use the filename (E.g '/Images/myImage.jpg' as string), or is their some other intricate method I should be using?

Thank you :)


Hmm, I really don't know which is faster as I haven't tried saving any image as a BLOB on the database. But I do know that saving a pointer to the image on the database is space-efficient as you don't get to use up unnecessary db space.

Also, how I do it is I save the directory the images are stored in as variable on a PHP file I'll include when access to the image is needed and then just concatinate that and the database-retrieved pointer and voila! I mean like so:

<?php
//filetoinclude.php
//some other stuffs to include

$imagesDirectory = "images/";
...



Then after I retrieve the pointer, I concatinate both and use like so:
...
include 'filetoinclude.php';
...
$filepointer = "creativecoding.jpg";

$imageFullPath = $imagesDirectory.$filepointer;



there you have it(my way, that is)!
Was This Post Helpful? 2
  • +
  • -

#3 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2486
  • View blog
  • Posts: 8,533
  • Joined: 08-August 08

Re: Storing Images

Posted 15 July 2011 - 03:14 PM

It is almost always faster to store the path instead of the image in the database, and it puts less load on your database server.
Was This Post Helpful? 2
  • +
  • -

#4 E_Geek  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 45
  • View blog
  • Posts: 236
  • Joined: 20-February 11

Re: Storing Images

Posted 16 July 2011 - 01:29 AM

Thankyou :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1