Hi,
I am using classic ASP. I have few images in my folder, which is inside the wwwroot of the server. I am trying to display the images in a ASP page. Below is the code i have used.
<% Option Explicit %>
<html> <head> <title>Untitled</title> </head>
<body>
<form action="<%= Request.ServerVariables("SCRIPT_NAME") %>" method="post">
<input type="text" name="directory" value="D:\NewFolder\"/>
<input type="submit">
</form>
<%
Dim strPath, fso, fsoFolder, fsoFile, i
If Request.Form("directory") <> "" Then
strPath = Request.Form("directory")
If Not Right(strPath, 1) = "\" Then
strPath = strPath & "\"
End If
Set fso = Server.CreateObject("Scripting.FileSystemObject")
If fso.FolderExists(strPath) = True Then
Set fsoFolder = fso.GetFolder(strPath)
i = 1
For Each fsoFile In fsoFolder.Files
If UCase(fso.GetExtensionName(fsoFile.Name)) = "JPG" Or
_ UCase(fso.GetExtensionName(fsoFile.Name)) = "GIF" Then
i = i + 1
Response.Write "<img src=""" & strPath & fsoFile.Name & """ height=""80"" border=""0"" alt=""" & fsoFile.Name & """>"
If i = 10 Then Response.Write "<br>"
End If
Next
Else
Response.Write("Folder " & strPath & " does not exist.")
End If
Set fso=nothing
Set fsoFolder=nothing
End If
%>
</body> </html>
The images are existing in the computer itself. In the output, i am getting the broken image icon only.
How to display the images in ASP?
Thank you
Thread Closed
This thread is kinda stale and has been closed but if you'd like to continue the conversation, please create a new thread in our Forums,
or Contact Us and let us know.