FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Storing Images





polly-gone
What is the best way to store images? Is it best to store images all in one folder and have a database filled with the URLs, or is it possible to directly store images in a database?

Thanks,

-Nick Smile Smile Smile
badai
you can store directly in database using blob.

i'm not sure which one is better.

maybe if you store in folder is easier, where you can view the image directly. i mean when you access your server directly, not for user that browsing your site.
imagefree
yes it is possible to directly store images in database, but when your number of images will increase (just about 100 and more) query response time will start increasing and your system will get slower and slower.

it is best to save files/images on file system (folder).
leontius
It is best to just store the path/filename to the images in the database and store the images as files. That way you can let the http server (apache) to serve the images. If you store the images in the database, they must go through the database and PHP first before you can serve them.

If you can, avoid using blobs. They are inefficient. Only use them if you need ACID for your binary data. (Even then, writing the data to a temporary file, renaming the original file, renaming the temp file to, and then delete the original file usually will suffice. See e.g. http://blogs.msdn.com/adioltean/archive/2005/12/28/507866.aspx for atomic file writes.)
tukun2009manit
polly-gone wrote:
What is the best way to store images? Is it best to store images all in one folder and have a database filled with the URLs, or is it possible to directly store images in a database?

Thanks,

-Nick Smile Smile Smile


saving image in a folder is best option and storing its url in db
its easy to handle
Raidation
It's better to store in a folder.
And then save the urls in a database.


Text takes up less storage than images, and images in a folder can be shown.
Aredon
I agree with what's been said here for the most part. You should definitely keep images as files. It's just faster and easier to work with. Especially if you need to rename an image, or even edit it if you're using FTP and keeping your images there. The only time I'd use blob images would be for like user avatars and such. Anything that needs to be user-submitted.
chatrack
I remember a script that can convert image file in to binary format and store
the data of image file in database. It will take more space, and as mensioned
in earlier post, it will affect image retriving time

So, it is better to store Image in some folder or URL and store imageURL in
database
Marcuzzo
chatrack wrote:
I remember a script that can convert image file in to binary format and store
the data of image file in database. It will take more space, and as mensioned
in earlier post, it will affect image retriving time

So, it is better to store Image in some folder or URL and store imageURL in
database



when you don't have a lot of images there is no problem in storing the images directly into the database.

but when you have several pictures you are best off by uploading the pictures to a directory and storing the path in a database table, as mentioned before
rvec
Marcuzzo wrote:
chatrack wrote:
I remember a script that can convert image file in to binary format and store
the data of image file in database. It will take more space, and as mensioned
in earlier post, it will affect image retriving time

So, it is better to store Image in some folder or URL and store imageURL in
database



when you don't have a lot of images there is no problem in storing the images directly into the database.

but when you have several pictures you are best off by uploading the pictures to a directory and storing the path in a database table, as mentioned before
You'll still have the problem that it'll be unnecessary slow and take much more recourses than storing them as files.
The-Nisk
Glad I came across this post, this was something I had to decide upon soon enough! Thanks!
polly-gone
Just an update:

I tested out my options, both storing an image and a url and storing just an image in a database, and the URL method is definitely the way to go. It takes WAAAAY too long for the images to be pulled from the database, but retrieving a URL, then image happened a LOT faster!

Thanks,

-Nick Smile Smile Smile
Related topics
W3C buttons without images
GIF and JPEG.
Some nature's images
Good photoshop images
wont load images
[tutor] How to protect images without htaccess using PHP
all images appear corrupt!
What do you use to make your page layout?
suggestion on posting pic
Test website
Images in MySQL
host images?????
Moving images from database to filesystem
Store images on frihost server or outside.
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.