Load image from file in my ASP to display to the browser 
Author Message
 Load image from file in my ASP to display to the browser
I have an ASP that retreives JPG images from my SQL table and displays it to
the screen.

Which I do:
Response.ContentType = "image/jpeg"
....querying the database here
Response.BinaryWrite rs("ImageField")
Response.Flush

Which works fine.

And the page calling my ASP is doing an <img src="myasp.asp?id=1">

Now, I want to:  In my ASP if image field is empty or null, I want to load
an image from file which will be a jpg called "NoImage.JPG"

How do I do this?



Mon, 09 Dec 2002 03:00:00 GMT  
 Load image from file in my ASP to display to the browser
I suppose the information stored in Rs("ImageField") is probably returned as
a bytearray. Therefore if the UBound of the array is 0 then there must be a
blank entry.

->
...
Response.ContentType = "image/jpeg"
...
If UBound(Rs("ImageField")) <> 0 Then
 Response.binaryWrite Rs("ImageField")
Else
 Response.binaryWrite SomeOtherByteArray
End If
...
<-

As for where you get the other image from I have no idea because I don't
know what the rest of your code is like, however you might be able to
response.redirect to it (cheeky but it might work).

--
Dominic



Mon, 09 Dec 2002 03:00:00 GMT  
 Load image from file in my ASP to display to the browser
Yeah......

But at this point, how would I load an image from a file to return??


Quote:
> I suppose the information stored in Rs("ImageField") is probably returned
as
> a bytearray. Therefore if the UBound of the array is 0 then there must be
a
> blank entry.

> ->
> ...
> Response.ContentType = "image/jpeg"
> ...
> If UBound(Rs("ImageField")) <> 0 Then
>  Response.binaryWrite Rs("ImageField")
> Else
>  Response.binaryWrite SomeOtherByteArray
> End If
> ...
> <-

> As for where you get the other image from I have no idea because I don't
> know what the rest of your code is like, however you might be able to
> response.redirect to it (cheeky but it might work).

> --
> Dominic



Tue, 10 Dec 2002 03:00:00 GMT  
 Load image from file in my ASP to display to the browser
Have you tried the Response.Redirect method? There is no way to open a
binary file through VBScript or using the FSO, you must create your own
object or use a third party control.

--
Dominic



Tue, 10 Dec 2002 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. ASP Load image from file to display in browser

2. how do I display a 'page loading...'- image while actual page is loading

3. Loading a selected file into an external image browser

4. Displaying images stored in an Image field from an ASP

5. displaying image in a browser

6. Display Image in picturebox from db image field without temp file

7. Object to load a word document into for display in asp.net

8. ActiveX SmartViewer loaded from ASP does not display report

9. Save and load images from ASP

10. ASP.NET: Display images from database

11. Display Filed Description, Filed Data Type on ASP Page

12. ASP Returning a DIB Image (I think) from SQL , Netscape doesn't display it

 

 
Powered by phpBB® Forum Software