Iam trying to build a simple image gallery,that displays image form the files on web server and displays it on webpage. I tried, but my code displays some random text instead of an image. Here is the code: <%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <% dim objFSO,objFolder,objFile,objOpen Set objFSO=Server.CreateObject("Scripting.FileSystemObject") Set objFolder=objFSO.GetFolder(Server.MapPath("hall")) for Each objFile in objFolder.Files Set objOpen=objFile.OpenAsTextStream(1) do while Not objOpen.AtEndOfStream Response.Write objOpen.ReadAll Loop objOpen.Close Response.Write "<br>" Next Set objOpen=nothing Set objFolder=nothing Set objFSO=nothing %> </body> </html> Code (markup): What is happening? How can I display the image from a file? Plz help..
Try this <%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%> <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <% dim objFSO,objFolder,objFile,objOpen Set objFSO=Server.CreateObject("Scripting.FileSystemObject") Set objFolder=objFSO.GetFolder(Server.MapPath("hall")) for Each objFile in objFolder.Files Response.Write "<img src=hall/"& objFile.Name & ">" Response.Write "<br>" Next Set objOpen=nothing Set objFolder=nothing Set objFSO=nothing %> </body> </html> Code (markup):
thnx for replying. I tried but it gives an error: What does this mean now? What should I do to resolve it?
perhaps there are too many files in that folder or many files are not image files and those files keep running.
there r five images in that folder and all are compressed. but when I view the properties of that folder, it shows there r 6 files. I don't see the sixth file..not even when I opted to view the hidden files. I don't knw from where it came. But yes when I was trying to find out the sixth file I saw somewhere its a DB file..but how to access that file? And I never put a DB file..so from where did it came? nyways..now the question is how to acces that file and delete it from there?
I found the DB file. IIS shows a thumbs.db file. which file is it? Iam not able to access the file. Can I delete it?
Yes, you can deleted it. Can you ASP.Net instead? I have a script I use to do this written in .Net in about 3 lines.
thnx. I deleted the file. I also searched on the net and selected not to cache the thumb images. But still I have the same error message. blogsalesman, thnx so much but I would like to do it in ASP( Iam a newbie and trying to learn). Can you plz help me with that?
btw can you tell me a good book for asp.net. I would like to start with it. n yeah can you also give me the script that you have to resolve my problem?
you may try if right(objFile,4)=".jpg" or right(objFile,4)=".gif" then Response.Write " : <img src=http://domain_com/image_file/"& objFile.Name & ">" end if an example code info at http://3w.ezer.com/asp/file/server.mappath.asp
works fine here. as the example code showing you may narrow down images from countI<100 to countI<10 or countI<2 and recheck your mappath and <img src=http://self_domain_com/image_folder/"& objFile.Name & ">" use self_domain_com same as it belongs , do not use other domains