Click here to Skip to main content
14,236,179 members
Rate this:
Please Sign up or sign in to vote.
See more:
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.
Posted
Rate this:
Please Sign up or sign in to vote.

Solution 1

Create a User Control in ASP.NET with Upload control and Insert it as a Macro in Umbraco

Hope this information helps
   
Rate this:
Please Sign up or sign in to vote.

Solution 2

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;
        }
    }
}
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100