<%@ Page Title="Auto 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)
    {
        var destinationFolder = Server.MapPath("~/App_Data/DemoSaves");
        System.IO.Directory.CreateDirectory(destinationFolder);

        var extension = System.IO.Path.GetExtension(e.FileName ?? string.Empty);
        var savedName = System.Guid.NewGuid().ToString("N") + extension;
        new AjaxUploader.Services.UploadService().CopyFile(
            e.FileGuid,
            System.IO.Path.Combine(destinationFolder, savedName));

        lblSaved.Text = "Saved " + Server.HtmlEncode(e.FileName)
            + " to App_Data/DemoSaves/" + savedName + ".";
    }
</script>
<asp:Content ID="TitleContent" ContentPlaceHolderID="TitleContent" runat="server">Auto Upload - AjaxUploader v5.3 Demos</asp:Content>
<asp:Content ID="HeaderContent" ContentPlaceHolderID="HeaderTitle" runat="server">Auto Upload</asp:Content> 
<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server"> 
<div class="demo-card"> <div class="demo-card-header">Auto Upload</div> <div class="demo-card-body"> <p class="demo-description"> Files begin uploading immediately after selection. This is enabled with
 <code>AutoUpload="true"</code>. No separate upload button is needed.
 </p>
 <div class="demo-expect"><strong>What you should see:</strong> pick any file and the upload starts immediately &mdash; no button press. When the queue completes, the page posts back, <code>FileUploaded</code> saves a server-side copy, and the confirmation below names its safe destination.</div> <au:AjaxFileUpload ID="Uploader1" runat="server"
 AllowMultiple="true"
 AutoUpload="true"
 AutoPostBack="true"
 ButtonText="Select Files (Auto Upload)"
 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 files to upload and save them through FileUploaded." /></div> <div class="code-panel"> <pre><code>&lt;au:AjaxFileUpload ID="Uploader1" runat="server"
 AllowMultiple="true"
 AutoUpload="true"
 AutoPostBack="true"
 ButtonText="Select Files (Auto Upload)"
 OnFileUploaded="Uploader1_FileUploaded"
 ShowProgress="true" /&gt;</code></pre> </div> </div>
</div> 
</asp:Content>
