Umbraco CMS中的文件上传控件 [英] File Upload Control in Umbraco CMS

查看:64
本文介绍了Umbraco CMS中的文件上传控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,



我是Umbraco CMS的新手。

我想在我的页面中创建文件上传控件。 />
所以任何人都可以告诉我如何以最简单有效的方式创建它。

Hello,

I'm new in Umbraco CMS.
I want to create file upload control in my page.
So can any one tell me how to create it with easiest and efficient way.

推荐答案

在ASP.NET中使用上传控件创建用户控件并将其作为宏插入Umbraco



希望此信息有用
Create a User Control in ASP.NET with Upload control and Insert it as a Macro in Umbraco

Hope this information helps


您可以使用FileUpload元素。



You can use FileUpload element.

<form id="form1" runat="server">
    <asp:FileUpload id="FileUploadControl" runat="server" />
    <asp:Button runat="server" id="UploadButton" text="Upload" onclick="UploadButton_Click" />
    <br /><br />
    <asp:Label runat="server" id="StatusLabel" text="Upload status: " />
</form>







protected void UploadButton_Click(object sender, EventArgs e)
{
    if(FileUploadControl.HasFile)
    {
        try
        {
            string filename = Path.GetFileName(FileUploadControl.FileName);
            FileUploadControl.SaveAs(Server.MapPath("~/") + filename);
            StatusLabel.Text = "Upload status: File uploaded!";
        }
        catch(Exception ex)
        {
            StatusLabel.Text = "Upload status: The file could not be uploaded. The following error occured: " + ex.Message;
        }
    }
}


这篇关于Umbraco CMS中的文件上传控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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