Jag skulle vilja läsa en bild som inte ligger i webbträdet. Har testat med detta:
<BODY BGCOLOR="white">
Här ligger en bild.<br>
<img src="test2.asp">
</BODY>
test2.asp:
Set fso = CreateObject("Scripting.FileSystemObject")
Set bildfil = fso.OpenTextFile("d:\bilder\Arthur.gif")
text = bildfil.ReadAll
bildfil.Close
Set fso = Nothing
Response.ContentType = "image/gif"
Response.BinaryWrite(text)
Nej, jag får inte något felmeddelande. Bilden visas bara inte. Tar jag bort content-type och skriver ut binärkoden känns det som att jag får ut för lite kod. Det känns även lite fel att använda en metod som heter OpenTextFile när det gäller en gif-bild.
The FSO model, contained in the Scripting type library (Scrrun.dll), supports the creation and manipulation of text files through the TextStream object; however, the FSO model does not support binary files.
Du kanske kan använda dig av GetFile()? Jag har aldrig testat detta, men jag vill ju gärna hjälpa :)
Dim fsoFile, fso
Set fso = CreateObject("Scripting.FileSystemObject")
Set fsoFile = fso.GetFile("d:\bilder\Arthur.gif")
Response.ContentType = "image/gif"
Respone.BinaryWrite (fsoFile)
Set fsoFile = Nothing
Set fso = Nothing