The absolute minimum code required to add a working file upload to your page.
Just one server control is all you need.
What you should see: select a file, then the page confirms it was saved to App_Data/DemoSaves/MinimalSetup. The folder is real and persistent, but IIS does not serve App_Data.
Drag & drop files here, or paste from clipboard
Nothing saved yet. Select a file to upload it and write a permanent server-side copy.
<%@ Register Assembly="AjaxUploader" Namespace="AjaxUploader.Controls" TagPrefix="au" %>
<au:AjaxFileUpload ID="Uploader1" runat="server"
OnFileUploaded="Uploader1_FileUploaded" />
protected void Uploader1_FileUploaded(object sender,
AjaxUploader.Events.FileUploadedEventArgs e)
{
var name = Guid.NewGuid().ToString("N")
+ Path.GetExtension(e.FileName ?? "");
new AjaxUploader.Services.UploadService().CopyFile(e.FileGuid,
Server.MapPath("~/App_Data/DemoSaves/MinimalSetup/" + name));
}
What Happens Behind the Scenes
- The server control renders a styled file input with upload button
- When a file is selected, it is uploaded via AJAX to the handler URL
- The completion event copies it into a permanent folder on the server
- The page confirms the stored filename after its automatic postback