|
Posted by Jerry Stuckle on 06/08/07 21:01
K. wrote:
> Hello all!
>
> I have a question to you.
>
> I would like to create photo gallery.
>
> I wonder if I should store photos (uploaded by users) in database
>
> $data = file_get_contents($_FILES['photo']['tmp_name']);
> $data = mysql_real_escape_string($data);
> // Preparing data to be used in MySQL query
>
> mysql_query("INSERT INTO {$table}
> SET ext='$ext', title='$title',
> data='$data'");
>
> $msg = 'Success: image uploaded';
>
> or I should store uploaded photo files as files in the server folder?
>
> Few years ago in my previous work I worked in MS Access application, and
> in my opinion storing photos in this database are not so good, becuase
> uploaded
> photo files stored in MS Access application, enlarged the database a few
> times.
> That`s why storing such files in database is not so relevant and the better
> way
> was to saved these files in the specified folder.
> What about Mysql?
>
> Could you give me your opinions?
> M.
>
>
I store images in databases all the time. It works well. Sure, the
files can get large - but no larger than the individual files put
together are. In fact, the database is generally smaller than the sum
of the files because the db can manage disk space more effectively.
If you do a lot of adding and deleting in the database your files may
become larger due to empty space, but databases are generally pretty
good at reusing that space where possible. You just may need to
compress the database occasionally if this occurs.
Databases work well with huge numbers of images - they're made to handle
large numbers of rows. File systems aren't. 100K rows to a database is
nothing. But try to put that many files in one directory.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
[Back to original message]
|