473,789 Members | 2,860 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

photos stored in database or as files

K.
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_conten ts($_FILES['photo']['tmp_name']);
$data = mysql_real_esca pe_string($data );
// Preparing data to be used in MySQL query

mysql_query("IN SERT 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.
Jun 8 '07 #1
10 2277
K. wrote:
I wonder if I should store photos (uploaded by users) in database
I would recommend not doing so. Storing them in files and then referencing
them by filename in the database is probably better. It will make for much
easier incremental backups.

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.12-12mdksmp, up 104 days, 18:13.]

URLs in demiblog
http://tobyinkster.co.uk/blog/2007/05/31/demiblog-urls/
Jun 8 '07 #2
K.

U¿ytkownik "Toby A Inkster" <us**********@t obyinkster.co.u knapisa³ w
wiadomo¶ci news:ll******** ****@ophelia.g5 n.co.uk...
K. wrote:
>I wonder if I should store photos (uploaded by users) in database

I would recommend not doing so. Storing them in files and then referencing
them by filename in the database is probably better. It will make for much
easier incremental backups.
Yes maybe it is better for backups, but what about the size of the database
after uploading many photos?

Thank you for post
Marcin
Jun 8 '07 #3
K. wrote:
Yes maybe it is better for backups, but what about the size of the database
after uploading many photos?
The database will remain small. Read my original post again carefully.

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.12-12mdksmp, up 104 days, 21:09.]

URLs in demiblog
http://tobyinkster.co.uk/blog/2007/05/31/demiblog-urls/
Jun 8 '07 #4
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_conten ts($_FILES['photo']['tmp_name']);
$data = mysql_real_esca pe_string($data );
// Preparing data to be used in MySQL query

mysql_query("IN SERT 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.
js*******@attgl obal.net
=============== ===
Jun 8 '07 #5
K.

Uzytkownik "Jerry Stuckle" <js*******@attg lobal.netnapisa l w wiadomosci
news:Ys******** *************** *******@comcast .com...
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_conten ts($_FILES['photo']['tmp_name']);
$data = mysql_real_esca pe_string($data );
// Preparing data to be used in MySQL query

mysql_query("IN SERT 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.
OK. Thank you for the efficient explanaition. I understood everything.
It is logic and now I will know what I should do during builidng the
database.
Jun 11 '07 #6
Jerry Stuckle schrieb:
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.
Databases are meant to store huge *numbers* of records that can be
quickly indexed and searched. They're not meant to store big blobs of
binary data.

So use the appropriate tool for *each* part of the job.

Nearly every good CMS that handles images will use a folder in the file
system combined with a MySQL table of file names. There is no practical
limit to the number of files in a file system; the only performance
issue you get is when you try to list all of them at once or search for
one.

But give it a specific path (which MySQL found in its table in an
instant) and the file system will find your file immediately, regardless
of how many other files there are in the directory.

--
cb
Jun 13 '07 #7
Christoph Burschka wrote:
Jerry Stuckle schrieb:
>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.

Databases are meant to store huge *numbers* of records that can be
quickly indexed and searched. They're not meant to store big blobs of
binary data.
And where did you get that from? They work just great for images.
So use the appropriate tool for *each* part of the job.
I do.
Nearly every good CMS that handles images will use a folder in the file
system combined with a MySQL table of file names. There is no practical
limit to the number of files in a file system; the only performance
issue you get is when you try to list all of them at once or search for
one.
So "nearly every good CMS..."? What does that prove? Absolutely
nothing, maybe? And when was the last time you tried to handle 100K
pictures in a single directory? Databases handle this quite easily.
But give it a specific path (which MySQL found in its table in an
instant) and the file system will find your file immediately, regardless
of how many other files there are in the directory.
No, it won't. Try putting 100K files in a directory and see how long it
takes to find one. Also, see how much space they take. Unless they're
each a multiple of 512 bytes, you'll get a lot of wasted space.

Now repeat with MySQL. Not only will retrieval be faster, the files
will take less space.
--
cb
You've obviously never tried it, have you?

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Jun 13 '07 #8
Jerry Stuckle wrote:
Also, see how much space they take. Unless they're
each a multiple of 512 bytes, you'll get a lot of wasted space.
Certain filesystems (e.g. ReiserFS and JFS) use block suballocation
allowing multiple files or part-files to share the same block, which
makes the storage of many small files very efficient.

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.12-12mdksmp, up 109 days, 21:40.]

URLs in demiblog
http://tobyinkster.co.uk/blog/2007/05/31/demiblog-urls/
Jun 13 '07 #9
Toby A Inkster wrote:
Jerry Stuckle wrote:
>Also, see how much space they take. Unless they're
each a multiple of 512 bytes, you'll get a lot of wasted space.

Certain filesystems (e.g. ReiserFS and JFS) use block suballocation
allowing multiple files or part-files to share the same block, which
makes the storage of many small files very efficient.
Toby,

Yes, I understand. But there's still a larger amount of overhead in
those filesystems than there is with a database - even with an index.

Additionally, how many hosting companies are using ReiserFS and/or JFS?

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Jun 13 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
11488
by: Suresh Tri | last post by:
Hi all, I am interested in extracting the class or jar files which are stored as java stored procedures in Oracle. But I want to know if these are stored as references to external files in Oracle database or directly inside the database. In case if it is directly stored inside the database is there any way to extract it?. If I can extract these java files, can these be used in non Oracle applications? Please help,
7
1742
by: Jeremy Simpson | last post by:
Can someone please help me with this? I am trying to put my jpg photos in my database. Access books seem to avoid the issue of graphics in DB tables and my searches on the internet seem to point me away from putting photos into tables (ultimately on forms). Has anyone successfully put viewable jpg's in their forms? Thanks Jeremy
3
2374
by: Dirk Goossens | last post by:
Hi! I stored the file name and path of photos in a table with data from students and teachers. Is there a way to show the photos in a report or form? Thanks! Dirk Goossens Vrij Instituut Sint-Lucas - Oudenaarde
1
1929
by: RSH | last post by:
Im trying to create a stored procedure of the following code. I want to set it so that I have to send the first 4 variables (@DB, @BackUpFile,@TestDB,@RestoreFile). I am having trouble when i try to save it...SQL Server wants me to decalre the variables. How would I go about making this a stored procedure correctly? Here is the code: USE master GO
4
2272
by: Dave G | last post by:
Firstly, apologies as this is not strictly an Access problem. I have a Access 2003 database containing records about people, and each person has 2 photos associated with the record. The photos are stored in a 'photos' folder. When a record is displayed, so are the photos. It all works fast and well. But I'm now getting close to 50,000 records and although it still works well I'm worried about having 100,000 jpgs in one folder.
1
3113
by: gm | last post by:
Hi; I have written a database that tracks all the installation we have ever done. I have a small heating company. I have recently started keeping a directory of digital photographs of the completed job. I can create a hyperlink button that will link to a photgraph, but I cannot link to a specific photo of that specific job. Each job has its' own unique identifier, I call it the GOTC number. It is a separate field in the table of installed...
2
2285
by: Frankie | last post by:
Using SQL Server 2005 and .NET 2.0; I'm creating a Windows Forms application that will need to display photos of people, along with a bunch of information about each person. In a Web application, there is a generally accepted "best practice" of storing only a string (the path to the .jpg file name), with the actual file stored in an NTFS folder (and not in the database). What's the standard practice for Windows Forms applications? Is...
1
1458
by: jojo41300000 | last post by:
Hi, I am writing an application which will display the photos on the web pages. The photos are stored in the seperate machine but in the same LAN. First, when the user visit the web site, the photos are shown as small size. Then, when the user click on the photo, it will show the larger size on another Image box in the same page. I tried using ImageMap, It works. But, when I look up the client code, it has the physical...
22
4056
by: skysober | last post by:
I have read and read about mysql, which I am sure is just like the quoted, "linux is very friendy, but it just chooses who it wants to be friends with..." My first attempt to read the database in my forum actually works! Well, almost. It does query the correct places, lists the information, and I have even figured out how to see a full path to where the photo is stored. But is never actually SHOWS the image. My eventual goal is to...
0
9511
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10410
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10200
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10139
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9984
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7529
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3701
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2909
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.