I am uploading image.While uploading images i am saving image name and the link for that iage in one textfile. like this, abc.jpeg,http://google.com
Now i want to display all that images with corresponding links using classic asp.
How should I do this?
Please help.
I used this asp code:
<%
For Each FileName in fold.Files
Dim Fname
Dim strFileName
Dim objFSO
Dim objTextFile
Dim URLString
Dim strReadLineText
Fname= mid(FileName.Path,instrrev(FileName.Path,"\\")+1)
strFileName = "../admin/Links.txt"
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile(Server.MapPath(strFileName))
URLString=""
Do While Not objTextFile.AtEndOfStream
strReadLineText = objTextFile.ReadLine
'response.Write(strReadLineText & "<br>")
If strReadLineText<>"" then
If Instr(strReadLineText,",")>0 then
strReadLineTextArr=split(strReadLineText,",")
response.Write(strReadLineTextArr(0))
URLString=strReadLineTextArr(1)
end if
end if
Loop
' Close and release file references
objTextFile.Close
Set objTextFile = Nothing
Set objFSO = Nothing
its displaying all images but for all images link is same.its reading directly the last link from textfile....What is the problem with my code?
You could try something like this -
Your problem is the way you assign URLString. It starts off as "", and as you read through each line in the file, you overwrite it's existing value. The last line of the file will be the last overwrite, so that'll be the value inside of URLString at the end of the loop. An example of code is:
This removes extra whitespace around any text and simply writes a list of series images. The one flaw this has is that if a filename has a comma in it, it'll break.