473,406 Members | 2,549 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Storing images in folder or database?

Hello,

I am working on an ASP.NET based website project. Without going into
much detail; One of the function on this website will be the
possibility to upload images via a ASP.NET form to the webserver. These
images can then be shown on to webpages throughout the site.

What would be the best way of storing these images? Just by saving them
in a folder on de webserver or in a database?

What are the advantages and disadvantages of both working methods?

Thanks.

Nov 23 '05 #1
4 4619
I have faced this problem twice and each time I elected to put them in the
file system and then have some table that tracks filenames and associates to
an object in the database. Obviously you lose referential integrity but it
is possible to write a little program that checks that a row in the table
exists for each file name and a filename exists for each row in the table.

On one project we have 12GB of files and the database is only 500meg in
size. The management of the DB would have been more difficult if all of the
files were stored in it.

If you have a lot of files it is important to choose a good naming scheme
and directory structure. Our scripts automatically create a directory per
year per month per day of month. ie Files\2005\04\31\ In that way no one
directory becomes too large.

Backing up the data is also a breaze - xcopy.

You have to structure the transaction during the upload. If you start a
transaction, wait for the file to upload, add it to the database, add it to
the file system and then commit the transaction then you will have some long
running locks. Be careful that if the file does not upload correctly then
everything is clean up as expected.

There is some more code to write to manage the files and directories and the
database but it is a solution that works well.

I hope this helps. Feel free to contact me if you want more information (or
even code)

Dave A

"IkBenHet" <ik********@hotmail.com> wrote in message
news:11*********************@g49g2000cwa.googlegro ups.com...
Hello,

I am working on an ASP.NET based website project. Without going into
much detail; One of the function on this website will be the
possibility to upload images via a ASP.NET form to the webserver. These
images can then be shown on to webpages throughout the site.

What would be the best way of storing these images? Just by saving them
in a folder on de webserver or in a database?

What are the advantages and disadvantages of both working methods?

Thanks.

Nov 23 '05 #2
I have faced this problem twice and each time I elected to put them in the
file system and then have some table that tracks filenames and associates to
an object in the database. Obviously you lose referential integrity but it
is possible to write a little program that checks that a row in the table
exists for each file name and a filename exists for each row in the table.

On one project we have 12GB of files and the database is only 500meg in
size. The management of the DB would have been more difficult if all of the
files were stored in it.

If you have a lot of files it is important to choose a good naming scheme
and directory structure. Our scripts automatically create a directory per
year per month per day of month. ie Files\2005\04\31\ In that way no one
directory becomes too large.

Backing up the data is also a breaze - xcopy.

You have to structure the transaction during the upload. If you start a
transaction, wait for the file to upload, add it to the database, add it to
the file system and then commit the transaction then you will have some long
running locks. Be careful that if the file does not upload correctly then
everything is clean up as expected.

There is some more code to write to manage the files and directories and the
database but it is a solution that works well.

I hope this helps. Feel free to contact me if you want more information (or
even code)

Dave A

"IkBenHet" <ik********@hotmail.com> wrote in message
news:11*********************@g49g2000cwa.googlegro ups.com...
Hello,

I am working on an ASP.NET based website project. Without going into
much detail; One of the function on this website will be the
possibility to upload images via a ASP.NET form to the webserver. These
images can then be shown on to webpages throughout the site.

What would be the best way of storing these images? Just by saving them
in a folder on de webserver or in a database?

What are the advantages and disadvantages of both working methods?

Thanks.

Nov 23 '05 #3
Hello Dave,

Thanks for your clear answer! So, basically it is integrity that you
can lose if the script is not structured in a good way. Of course some
reference code is welcome. Was is all done in ASP.NET? You can sent it
to my e-mail adres.

Thanks.

Nov 23 '05 #4
Hello Dave,

Thanks for your clear answer! So, basically it is integrity that you
can lose if the script is not structured in a good way. Of course some
reference code is welcome. Was is all done in ASP.NET? You can sent it
to my e-mail adres.

Thanks.

Nov 23 '05 #5

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

Similar topics

7
by: Benoit St-Jean | last post by:
I am looking at options/ways to store 12 million gif/jpg images in a database. Either we store a link to the file or we store the image itself in the database. Images will range from 4k to 35k in...
6
by: bissatch | last post by:
Hi, I am currently writing a news admin system. I would like to add the ability to add images to each article. What I have always done in the past is uploaded (using a form) the image to a...
4
by: Rednelle | last post by:
Greetings all, As a newbie, using Access 2000, I would appreciate advice on the best way to include pictures. I have developed a 'Home Inventory' database which can include jpeg thumbnails of...
0
by: IkBenHet | last post by:
Hello, I am working on an ASP.NET based website project. Without going into much detail; One of the function on this website will be the possibility to upload images via a ASP.NET form to the...
9
by: Adam J Knight | last post by:
Hi all, Just wondering whats everyones prefered method of storing images ? 1) File System 2) Database (SqlServer) (Seems to be easier, but has a performance hit) Appreciate some insight!!!...
9
by: Wayne Smith | last post by:
I've come up against a major headache that I can't seem to find a solution for but I'm sure there must be a workaround and I would really be grateful of any help. I'm currently building a web...
1
by: leen | last post by:
helo..i'm az...from kuala lumpur...i would like to ask a question about access...i have doing a project based on access...i have done it successfully but now the problem is size of the file...the...
2
by: Spondishy | last post by:
Hi, I've taken over a publishing application that stores images in a sql server db. The architecture is basically many load balanced web servers connecting to the db. When an image is pulled...
0
by: RussCRM | last post by:
I want to use a command button, say "cmdDisplayImage" to display/ transfer a captured image from the ezVidCap1 control to an image or OLE box on the same form such as "PhotoPreview" (not sure...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
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,...
0
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.