Storing Images in SQL Server - ASP storage and retrieve

M

Michael Walton

I need some help, because I am utterly confused with how to do this. I have
2 things that I need to figure out, and could use some sample code or just
some general direction:

1) I need to build an admin page that allows me to browse to the file that I
want stored in SQL Server 2000 in an image field, have it uploaded to the
server, and then stored in the db. I see this done all the time, so I don't
think this part is too hard, but I'm not sure how to get the image into the
db.

2) I want to display the image within a web page, so I would want to pull
the image out of the db, place it on my web server in a certain location,
and then reference the file in the HTML. How do I do that?

Thanks in advance for any help you can provide.

--Mike
 
F

Foo Man Chew

Why do you want to store the image in the database? This article really
helped me decide which way to go on this, and I'm glad I didn't use the
database for file storage after I've seen the headaches it's caused some of
my colleagues.

http://www.aspfaq.com/show.asp?id=2149

There are also links to knowledge base articles that show a few different
methods, with code samples, if it's really what you want to do. But I
highly recommend you reconsider.
 
M

Michael Walton

I normally just store images on the directory structure, but I am having a
real hard maintaining this in the environment that I am in. We have many,
many authors and they keep moving images, deleting images, renaming images,
and I end up with broken images, so I'd rather take care of it through the
ASP code, so they can't screw it up. I will check the link, though.
 
M

Michael Walton

Simpler isn't always best, unfortunately. Like I told Foo Man Chew, I have
control issues with the images being on the directory structure, so I need
to look into db methods. Thanks for the opinion, though (and I agree with
it).
 
C

Curt_C [MVP]

1) Actually it's not a good idea. Upload the image to the server and store
the Name/Location in the DB. look at www.darkfalz.com/1043 for a simple
upload script.

2) Much simplier if you have the image on the server.... :}
 
F

Foo Man Chew

2) I want to display the image within a web page, so I would want to pull
the image out of the db, place it on my web server in a certain location,
and then reference the file in the HTML.

Read that sentence a couple of times, and think about how efficient that is
compared to <img src=/images/uploadedImage.jpg>
 
M

Michael Walton

Right - I totally understand. However, when that image isn't there, because
dumb-idiot content developer has moved it or deleted it, how efficient is
the empty image with the red x in it?? I totally understand what I am
asking, and unless you have a better way to control the images on the
server, I have to use the DB to do it. This will take the control away from
the content developer and put it back into my hands. Trust me....the way
you are telling to do it is the way I've done it for 10 years, but its not
working in this environment, because of the morons I'm dealing with.

--Mike
 
M

Michael Walton

Thanks, Foo. That link had some good information in it, as well as links
with great examples. Exactly what I was looking for.

I also appreciate the opinions that are out there....if I could do it that
way, I would continue to do so, but until they start hiring intelligent
people (or intelligent people start breeding), I'm stuck with this.

--Mike
 
B

Brynn

So your content guy has his web server, and you have your DB server
... right? That's gotta suck ... can he create a virtual folder for
the website ... a folder that is on your server?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top