How do I read a jpeg image from a folder on a server

L

Lucas Cowald

Hi,

How do I read a jpeg image from a folder on a server, and give it to a user
as a file that his browser would download it (stream it) directly without
sending any HTML tags.

Here is exactly why I need it:

1) User goes to a page image.asp
2) image.asp would connect to a database and check, if this user has already
downloaded the image before.
3) If the user has never downloaded the image, he will be able to
downloaded, If user has already downloaded the image before, a text will
show on his browser that he can't get it the second time.

What is the best way to acomplish this. Can you show a sample code in
VBscript/ASP?

Thank you in advance for your help.
 
C

Chris Marchal[MSFT]

A common way of dynamically sending images to a client is to load the image
into a stream, set the response object mime type and then write the image
data to the response stream. This is documented in:

HOW TO: Write Binary Files to the Browser Using ASP.NET and Visual C# .NET
http://support.microsoft.com/?id=306654

You should be able to layer the database check around this concept.

Chris Marchal
Microsoft UK Developer Support
This posting is provided "AS IS" with no warranties, and confers no rights.
 
L

Lucas Cowald

Hi Chris,

Thanks for your reply!
The problem is that the images are not stored in the database. They are
stored in folders as JPEGs. I only store the location of each image in the
database.

Is there a command in VBScript/ASP that would convert JPEG image into a
binary format (right in the ASP script) without the need for the image to
come out from the database?

Thank you,
Lucas
 

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

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top