472,791 Members | 1,779 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,791 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 4580
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...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth

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.