如何读取传统的ASP文本文件 [英] How to read text file in classic asp

查看:99
本文介绍了如何读取传统的ASP文本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我上传image.While上传图片我现在的储蓄映像名称,在一个文本文件的链接进行iage。
喜欢这个,
abc.jpeg,HTTP://google.com

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

现在我要显示所有使用传统的ASP相应的链接图像。

Now i want to display all that images with corresponding links using classic asp.

我应该怎么做呢?

请帮忙。

我用这个ASP code:

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

其显示的所有图像,但对于所有图像链接same.its直接读取文本文件,从最后一个环节....我的code中的问题是什么?

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 -

Dim lineData
Set fso = Server.CreateObject("Scripting.FileSystemObject") 
set fs = fso.OpenTextFile(Server.MapPath("imagedata.txt"), 1, true) 
Do Until fs.AtEndOfStream 
    lineData = fs.ReadLine
    'do some parsing on lineData to get image data
    'output parsed data to screen
    Response.Write lineData
Loop 

fs.close: set fs = nothing 

这篇关于如何读取传统的ASP文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆