This project is read-only.

File Upload Location

Nov 4, 2009 at 5:45 PM
Edited Nov 7, 2009 at 11:51 PM

What is the best way to upload a file to a fixed location - say you want to update an xml file like a sitemap, or data for a news-ticker, or other controls that are hard-coded? Is there a good way to override the placement of files into a new folder every month?


Nov 8, 2009 at 2:58 AM
Edited Nov 8, 2009 at 4:04 AM

Ok.  I think I get it.  We have the advantage that security (passwords) are already managed, so ...

Go to the page: /admin/Pages/Settings.aspx

Just above the last div tag, paste the following:

    <asp:FileUpload ID="FileUpload1" runat="server" />

    <asp:Button ID="btnupload" runat="server" Text="Upload" OnClick="btnupload_Click" />

    <asp:Label ID="lblStatus" runat="server" Text="" ForeColor="Black"></asp:Label>


    Switch to "Design" View and Double-Click the Upload Button, this will take you to the code-behind page at the btnupload_Click event.

Paste the following between the { } tags of the btnupload_click event.


  if (FileUpload1.HasFile)




                lblStatus.Text = "Uploading File " + FileUpload1.FileName;

                FileUpload1.SaveAs(Server.MapPath(Utils.RelativeWebRoot + "App_Data/") + FileUpload1.FileName);

                lblStatus.Text = "File Successfully Uploaded";




                lblStatus.Text = "Unable to save the file";





            lblStatus.Text = "You have to select a file to upload";



You're Welcome.