You are here: Re: Difference between storing files on folder and in mysql db « PHP Programming Language « IT news, forums, messages
Re: Difference between storing files on folder and in mysql db

Posted by Jerry Stuckle on 01/08/08 18:30

missmoo wrote:
> Hey,
>
> I would like to know what the differences are in terms of security,
> reliability and resources between storing user-uploaded images in a
> file or storing them in a mySQL database.
>
> Our company is starting an image-competition soon, and I am not sure
> if I should write the php script to insert the binary code into a
> mySQL database or if I should just store the files in a dedicated
> folder and the data about them in the mySQL database.
>
> We are expecting relatively big loads of files, at least 10,000 in the
> first 2 months.
>
> Which system should I use? Is there a real difference between the two?
> our server is apache2, if that has any effects on the answer..
>
> Thank you!
>
> Moriel Schottlender
>

Not a whole lot of difference. I've been doing images in RDB's since we
were putting scanned documents in DB2 back in the 80's. It works well.

Security isn't that much different. If the images are in files, you
need a system userid and password with write access to the files. If
they're in a database, you need the database userid and password. (Of
course, if the database is not accessible from the network, you need both).

The downside is that you cannot server images from a MySQL database with
a simple <img> tag. You need to write a script with will fetch the
image and display it, then put the name of that script in the <img> tag.
Not hard to do - it's only a few lines of code. And you can have a
single file with the image to be used passed as a query parameter.

I do both, just depending on what's needed. For instance, if the image
is tied to other data in the database (i.e. a product image for a
shopping cart), I'll typically store the image in the database. But if
it's unrelated to anything else (i.e. a common header image), I'll just
put it in the file system.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация