<%@ Page Title="Single File Upload" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" %>
<%@ Register Assembly="AjaxUploader" Namespace="AjaxUploader.Controls" TagPrefix="au" %>
<script runat="server">
    protected void Uploader1_FileUploaded(object sender, AjaxUploader.Events.FileUploadedEventArgs e)
    {
        // Files land in a temp store first; YOUR handler decides where they live.
        // AutoPostBack="true" makes this run automatically when the upload finishes.
        var savedName = System.Guid.NewGuid().ToString("N") + System.IO.Path.GetExtension(e.FileName ?? "");
        new AjaxUploader.Services.UploadService().CopyFile(e.FileGuid, "~/uploads/" + savedName);
        lblSaved.Text = "Saved <code>" + Server.HtmlEncode(e.FileName) + "</code> to <code>~/uploads/" +
            savedName + "</code> (" + e.FileSize + " bytes)";
    }
</script> 
<asp:Content ID="TitleContent" ContentPlaceHolderID="TitleContent" runat="server">Single File Upload - AjaxUploader v5.2 Demos</asp:Content>
<asp:Content ID="HeaderContent" ContentPlaceHolderID="HeaderTitle" runat="server">Single File Upload</asp:Content> 
<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server"> 
<div class="demo-card"> <div class="demo-card-header">Single File Upload</div> <div class="demo-card-body"> <p class="demo-description"> <strong>The simplest possible AjaxUploader setup.</strong> One file at a time, auto-upload
 on selection, progress bar. This is the default behavior when <code>AllowMultiple</code> is
 not set or set to <code>false</code>. Everything else - chunked transport, drag-and-drop,
 cloud upload, encryption, validation - is opt-in on top of this baseline.
 </p>
 <div class="demo-expect"><strong>What you should see:</strong> select a file and it uploads, the page posts back automatically, and the green strip names the exact path it was saved to under <code>~/uploads</code>. No save code, no button &mdash; this page IS the complete pattern.</div> <au:AjaxFileUpload ID="Uploader1" runat="server"
 ButtonText="Select a File"
 AutoUpload="true"
 AutoPostBack="true"
 OnFileUploaded="Uploader1_FileUploaded"
 ShowProgress="true" /> <div class="alert alert-success py-2 px-3 small mt-3" role="status"><asp:Label ID="lblSaved" runat="server" Text="Nothing saved yet - select a file and it is saved to ~/uploads automatically." /></div> <div class="code-panel"> <pre><code>&lt;%@ Register Assembly="AjaxUploader" Namespace="AjaxUploader.Controls" TagPrefix="au" %&gt;

&lt;au:AjaxFileUpload ID="Uploader1" runat="server"
 ButtonText="Select a File"
 AutoUpload="true"
 AutoPostBack="true"
 OnFileUploaded="Uploader1_FileUploaded"
 ShowProgress="true" /&gt;

// Uploads land in a temp store; save them in FileUploaded.
// AutoPostBack fires it automatically when the upload finishes.
protected void Uploader1_FileUploaded(object sender,
    AjaxUploader.Events.FileUploadedEventArgs e)
{
    new AjaxUploader.Services.UploadService()
        .CopyFile(e.FileGuid, "~/uploads/" + e.FileName);
}</code></pre> </div> </div>
</div> 
</asp:Content>
