Problem accessing image from database

Hi, I am trying to access an image stored in a database through ASP and JSP for ASP I am using msAccess database entering the image as a OLE Object and for Jsp I use a longblob datatype for both i use front end tools to insert the image in the record, i.e. access and MySQL-Front. How ever when retreiving the records I find that all the other columns show properly whereas the Image column returns the following:

MySQL            |      MSAccess
Image            |      Image            
[B@1603522       |      ?/
I would like to know how can I render the images in the resulting asp/jsp pages, do I have to store the image link and add that to the <img src=rs("image")> or is there another way to handle images? Moreover I would want the admins to update images, if possible, do i try copying files with local reference(client) to a specific folder on the server? Simply confused how to handle the image and what is the best data type in MS Access,SQL Server and MySql for images?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Don't put the IMAGE in the database. Just put the FILENAME in the database, upload the actual graphic, leave it as a graphic, and make a link to the graphic. Then you don't have any weird stuff in your database, you don't have to worry about binary files making your database 20 times bigger than it needs to be.
James RodgersWeb Applications DeveloperCommented:
web woman is correct, once an image is placed inside an Access db there is a 'wrapper' placed around the image and you cannot extract the image in any way, except within the actual database for display on a form or report. Store the images in a separate folder on the server and store the file name in the db, as per webwoman's suggestion,and reference the file by path/name in the source of the img tag.
I build a separate image display program where I feed the keys for my database.

sID = Request("ID")
sSql = "SELECT * FROM Images WHERE ID=" & sID
Set oRS = oConn.Execute(sSql)

Response.ContentType = oRS("ContentType") ' image/gif or image/jpg
Response.BinaryWrite oRS("ImageStore")
Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

AdsAuthor Commented:
I tried doing that  here is an example of what i want ( this one works on intranet but not on the internet)
  Dim fsoObject
  Dim filObject
  pth = request.form("Image")
  Set fsoObject = CreateObject("Scripting.FileSystemObject")
  Set filObject = fsoObject.GetFile(pth)
  temp = Server.MapPath("images")
  filObject.Copy temp & "\",True
  Response.write("<br><hr>" & pth & " copied successfully!<br><hr>")

<form action="filecopy.asp" method="post">
<input type="File" name="Image" Accept="jpg/gif">
<input type="Submit" value="Submit">
<br> Please make sure the file you choose should be in a public folder and not have restrictive permission set on it.

The point being the admin should be able to upload the images to a folder on the webserver if I want this to work i could use a direct link but that way if the no of images increase it becomes pointless using asp. hence i wanted to use imags from database :-)
BTW quintsystems  I didnt quite understand what you meant by a separate program? do ya mean some kind of controls? pls, pls, give me some suggestions ....
First, I assumed that you already had the image in the database and were trying to get it back out.  In a web page, you would display the image by making the separate program (code given before) to be the source in the image tag:

Response.Write "<img src='ImageDBView2.asp?ID=" & sID & "'>" or for link to image
Response.Write "<A HREF='ImageDBView2.asp?ID=" & sID & "'>Image</A>"

To upload an image you must have a form like:
<FORM METHOD="Post" ENCTYPE="multipart/form-data" ACTION="ImageDBUp2.asp">
<INPUT TYPE="file" size="40" MAXLENGTH="100" NAME="txtImageStore" VALUE="<%= sImageStore %>">

Let me know if you are interested in the actual upload code...There are free controls for that and a free non-control method.

Hope this helps.
AdsAuthor Commented:
I would like the admins to be able to change the images of employees, for that I am open to suggestion, at first I thought that adding the image to the database would be fine but as all of you seggest it is better to copy it in some folder and link it dynamically based on the record id however I can't expect the local admins to ftp the web server  each time they want to update the images, I am open to using a free control if u can suggest one. Thanks a lot for helping promptly :-)
Here is a link to a page with the free non-component method.

Galaxy Upload I think is the free component for an alternative.  Not sure where I got it.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AdsAuthor Commented:
Ok, I will try it out give me a couple of days and i will get back.
AdsAuthor Commented:
Hi, I tried the script, its basically giving the same error as my script, its something to do with permission at the ISP's end I would definitely say that your implementaion is cleaner and better but seems to do the same job, however when I try to run it on the ISP's Webserver it throws the error. On my intranet both scripts seem to do the job. Any suggestions?

The error message is:

sFullFilePath = X:\myisp\\images\img1.gif

Microsoft VBScript runtime error '800a0046'

Permission denied

/ULFile.asp, line 64
You CANNOT put a file outside of your web if you're using an ISP's space. They will most definitely NOT allow it. They may not even HAVE an X drive, and even if they do, they sure aren't going to give YOU access to it. That's NOT what you've paid for.
Yea...I can't ignore the permission denied message.  I am not up on how to deal with that.  Anyone else out there that can deal with this?
AdsAuthor Commented:
I myself was surprised how their server even allowed my script to throw that error however I have changed the drive letter and folder name on which the have hosted my application before posting, well they were definitely paid to store files :-) ) jokes apart, do I go about asking users(in my case the local admin) to ftp the web server and put images and then code for retreiving it? I know this is tricky but I even know there might be just some workaround? Anybody?
AdsAuthor Commented:
BTW I am trying to access (write) a file on my WEB that is an image subdirectory! however the filesystem object is taking it as a local drive on the Web Server and that is causing the problems.
It will take it as a local drive on the webserver -- it HAS to. That's the only way it can do it.

Use server variables to find out the physical drive letter/path to your web folders. Use that for writing the files.

Better yet, tell your ISP what you're attempting to do -- they will most likely set up a special folder for you with the right permissions. The permissions you have for ftp'ing files won't work for an anonymous user -- and ALL your uploads are going to be from anonymous users.
AdsAuthor Commented:
Hi today i tested a app that downloads and uploads files, deletes them on my ISP's web server. It does not use any controls I think you can check it out Its Wex Lite 2.1 I dont remember the exact URL but I think thats my solution. webwoman I dont think any ISP is going to do what you suggested even if they do they will charge good amount of money for things that can be otherwise done for free, quintsystems thanks a lot for atleast trying to be there, you too webwoman I think I'll split the points even though the answer was somewhere else. :-)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Languages and Standards

From novice to tech pro — start learning today.