简体   繁体   English

在经典ASP中显示表打开文件中的链接

[英]Display link to in table open file in classic asp

I have set for files in Upload folder. 我已经在上传文件夹中设置了文件。 Also file name & file created date is stored in Database. 文件名和文件创建日期也存储在数据库中。 Now I have to bind the table with record set & provide link to download file . 现在我必须将表与记录集绑定并提供下载文件的链接。 How I can achieve this ? 我该如何实现? All uploaded files present in Upload Folder. 上传文件夹中存在所有上传的文件。 Below is my code for the same. 下面是我的相同代码。

<%
    Do While NOT FileResultStatus.Eof  
    %>
   <tr>
     <td> <%= FileResultStatus.Fields("sr") %> </td>
      <%
         Dim  link
         link = Server.MapPath("Upload")
         link = link +"\" + FileResultStatus.Fields("filename")

      %>
     <td> <a href= "<%= link %> "</a>  <%= FileResultStatus.Fields("filename") %>  </td>
     <td> <%= FileResultStatus.Fields("records")  %> </td>
    </tr> 
<%

    FileResultStatus.MoveNext     
  Loop
%>
         </table>
    <%    
   FileResultStatus.Close
   Set FileResultStatus=nothing
   Connection.Close
   Set Connection=Nothing

   %>

I am not sure what your problem or question is. 我不确定您的问题是什么。 Please state more clearly what is not working. 请更清楚地说明什么不起作用。

Given that you are referencing the recordset in a correct way, there is one thing in that code that looks odd. 假设您以正确的方式引用记录集,那么该代码中有一件事看起来很奇怪。 The Server.MapPath function returns the physical path of Upload, iesomething like C:\\inetpub\\wwwroot\\my-application\\Upload which is clearly not what you want as a href in your link. Server.MapPath函数返回上载的物理路径,例如C:\\ inetpub \\ wwwroot \\ my-application \\ Upload,这显然不是您想要的链接中的href。 You want link like href="Upload/myfilenameFromRecordset.txt". 您需要类似href =“ Upload / myfilenameFromRecordset.txt”的链接。

The link should be a relative path to the file uploads folder, not the physical path. 该链接应该是文件上载文件夹的相对路径,而不是物理路径。

In your browser just type in the location to one of the known files and use that as the link. 在浏览器中,只需键入一个已知文件的位置,然后将其用作链接即可。 For example, if your download link that you type in looks like: 例如,如果您键入的下载链接如下所示:

http://yourserver/Upload/filename.ext

then your code should be: 那么您的代码应为:

Dim  link
link = "Upload/" + FileResultStatus.Fields("filename")

You may have to experiment with the above or 您可能需要尝试上述方法或

link = "./Upload/" + FileResultStatus.Fields("filename")

depending on your setup 取决于您的设置

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将记录从SQL Server数据库显示到ASP Classic中的表中 - Display records from SQL Server database into table in ASP Classic 经典ASP - 以数周或月为单位显示表中数据库的记录 - Classic ASP - display records from databse in the table Week-wise or month-wise sql select使用经典asp成对显示帖子 - sql select to display posts in pairs, with classic asp 经典ASP为什么屏幕上没有任何显示? - Classic ASP why nothing being display on screen? 使用具有架构的表的经典 Asp 插入数据库 - Classic Asp insert to DB with table that has schema 一旦我使用经典的asp,jquery和ajax从第一个下拉列表中选择一个值,如何显示所选项目的表格? - How to display a table of selected items once I select a value from the first drop down list using classic asp, jquery and ajax? 读取和写入数据 Excel 文件 Classic ASP - Reading and Writing Data Excel File Classic ASP 在Classic ASP中,打开和关闭多个连接是否会对性能产生重大影响? - In Classic ASP, are there major performance consequences of having several connections open and close? 如何在 SQL 中按类别显示结果并在经典 ASP 中显示 - How to show results by Category in SQL and display in classic ASP 经典的asp字符串,仅显示以某个字母开头的结果 - classic asp string to display only results beginning with a certain letter
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM