在Kentico中查看和下载通过表单上传的文件 [英] View and download files uploaded via a form in Kentico
问题描述
在Kentico中,如何使站点用户可以查看和下载其他用户通过表单上传的文件?
In Kentico, how can make it possible for site users to see and download files uploaded by other users through a form?
我在Kentico CMS中创建表格.用户可以正确填写并提交.我的表单有一个上传文件字段.
我做了一个新页面来显示提交表单的内容.为此,我使用具有效果的查询中继器".
看来查询工作良好.我编写了一个Transformation以表格式显示每条记录.
除文件字段外,所有记录和字段均显示良好.我找不到一种方法来生成已上传文件的链接,以将其分配给链接标记的href
属性.我使用这样的代码
I make a form in Kentico CMS. Users can fill and submit it properly. My form has an upload file field.
I made a new page to show the content of the submitted forms. For this, I use a "Query Repeater with effect".
It seems the Query works well. I write a Transformation to show each record in a table format.
All records and fields appear well except the file field. I can not find a way to generate a link of uploaded files to assign it to the href
attribute of a link tag. I use code like this
<a href="https://example.com/CMSPages/GetBizFormFile.aspx?filename=<%# Eval("UploadFile1") %>"> Download File</a>"
此代码的问题是<%# Eval("UploadFile1") %>
返回这样的字符串
The problem with this code is the <%# Eval("UploadFile1") %>
returns a string like this
94e5b02d-1bcd-4341-9930-6e5ef1029d8b.pdf/MyFileName.pdf
94e5b02d-1bcd-4341-9930-6e5ef1029d8b.pdf/MyFileName.pdf
我该如何解决这个问题?
How can I solve this problem?
推荐答案
我的一位朋友提出了一种行之有效的解决方案!
One of my friend suggested a solution that is works well!
1-首先获得对所有人的访问以读取表单记录.应用程序>权限>模块>表格
1- at the first get the access to Everyone to read form records. Applications>Permissions>Module>forms
2-转换代码:
<asp:PlaceHolder ID="ph1" runat="server" Visible='<%# IfEmpty(Eval("UploadFile1"), false, true) %>'>
<br>
<a style="color:blue;font-weight:bolder" href=<%# "https://example.com/CMSPages/GetBizFormFile.aspx?filename=" + Eval("UploadFile1").ToString().Split('/')[0] %>>Download File: <%# Eval("UploadFile1").ToString() == "" ? "a" : Eval("UploadFile1").ToString().Split('/')[1] %></a>
</asp:PlaceHolder>
第一行用于在没有任何上传文件的情况下不显示任何内容.
the first line is for show nothings if there is not any uploaded file.
这篇关于在Kentico中查看和下载通过表单上传的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!