将Uploated文件链接到Form记录 [英] Link Uploated files to Form record
本文介绍了将Uploated文件链接到Form记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨
我创建了一个asp.net应用程序表单插入,更新了sql数据库中的一些记录,我希望能够根据id上传和关联上传的文件到每个记录。我有你可以上传的表单文件,但我怎么能与每个记录和视图模式相关的文件看到该文件的链接??
提前谢谢
Hi
I created an asp.net application form inserting,updating some records in sql database and i want to be able to upload and relate uploated files to each record depending id.I have the form that you can upload files but how can i relate files with each record and on view mode see link to that file??
Thanks in advance
推荐答案
不确定我是否正确理解了您的问题。所以我做了一些假设。
- 我假设你想把一个文件分配给一个记录(上传与否在这里并不重要)
- 您希望在显示该记录时显示该文件的链接(再次。哪种模式无关紧要)
您所需要的只是将文件名存储在您记录的字段中(您还可以引用另一个表等)。
显示记录只是创建一个超链接,你链接到该文件夹(可通过网络访问)和文件..
示例:
用户上传文件testfile.txt,将文件存储到D:\\\\YourApplication\Files\testfile.txt
显示链接时,文件的相对路径可能是〜/ Files / testfile.txt(注意:代字号(〜)代表你的应用程序根目录。
所以你可以直接在录音机上存储〜/ Files / testfile.txt d或只记录文件中的文件名,当你生成< asp:hyperlink>
控件时,你可以设置NavigateUrl
它在此路径中的属性。
Not sure if I understand your question correctly. So I'm making a few assumptions.
- I assume you want to assign a file to a record (uploaded or not doesn't really matter here)
- You want to show a Link to that file when displaying that records (again. which mode doesn't really matter)
All you need is to store the filename in a field of you record (you can also have a reference to another table etc.).
When showing the record just create a Hyperlink where you link to the folder (accessible over the web) and the file..
Example:
User uploads file "testfile.txt" you store the file to "D:\www\YourApplication\Files\testfile.txt"
When showing the link the relative path to the file could be "~/Files/testfile.txt" (Note: the tilde char (~) is representing your application root.
So you could either store "~/Files/testfile.txt" directly on the record or just the filename itself on the record and when you generate the<asp:hyperlink>
control you can set theNavigateUrl
Property of it to this path.
这篇关于将Uploated文件链接到Form记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文