Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Placing an image in database

Status
Not open for further replies.

dand11

Programmer
Jun 24, 2008
63
US
I would like to set up an asp.net 2.0 web app to insert images into a SQL Server 2005 database. I'm hosting on godaddy shared hosting and they block the use of file streams for security purposes. Is there another way to get the images uploaded? I'd prefer to have them in the database so I could setup a SQL Server job to delete the records when they have expired so I won't have to go in and manually delete them and possibly make a mistake by deleteing one that is still being used. But I'm would be interested in other ways as well.
 
You have to send a byte array to a stored procedure that has a parameter data type as image. There are many examples on line.
 


The problem I've been having is that godaddy blocks the use of the asp.net stream object I would need to create the byte array. I end up getting some security error asking me to contact the administrator.
 
Oh, and as for deleting images, yes thats a fun task to do, and dangerous.

Root
--Images
--Upload
--1
--file.jpg
--2
--pic.gif
--3
--samurai.jpg


If you can mimic that folder structure where the number is the sql table record id, then you can run a cleanup routine to remove those folders if the ID doesnt exist in your table. Some document imaging programs use a similar concept (laserFiche)
 
Thanks, I'll have to look into it but I think I'll still have the problem of not being able to upload the image. Maybe I'll just use another host lik 1and1.com or something.
 
Godaddy doesnt let your website upload files? How rude!

1and1 is not much better.
 
Not on a shared host. Godaddy blocks the use of some ASP.Net functionlity (ie file streams). According to 1and1's web site it didn't list any restrictions on that and the support person said that there wasn't any problem with uploading images to the server....we'll see.
 
SQL server is fine for storing images. There are times when it is good and when it is bad. It depends on every situation. A blanket statement like "SQL Server is not good for storing images" could not be more incorrect. Right now we store all our images in a regular windows file system. In the begining it was fine, and now, it is a nightmare to say the least for maintenance. Try to efficiently update or delete a file in a file structure with 100,000 of thousands of images. SQL server would be better in this situation, and is the direction we are moving in now.
 
agreed its situation dependant,
i hope someone hosting on a shared host with GoDaddy wouldnt have a file structure with 100,000 of thousands of images!

i just realized my above link was from 2000, here is a more recent rant about yes or no with good comments below.

Seems medical field would be a good use of sql image storing. Again, i hope dand is not running a medical office through godaddy!

i am seeing this info, and some how-to's from a google search for sql 2005 storing images

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top