[英]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.