SAVING UPLOADED FILES
=====================

THE ONE THING TO UNDERSTAND
---------------------------
Uploads land in a TEMPORARY store first (App_Data\UploaderTemp by default) and
are swept after AjaxUploader.TempFileExpiryMinutes (default 60). An upload that
"succeeds" is NOT saved anywhere permanent until YOUR code saves it. If files
seem to vanish after a successful upload, this page is almost certainly why.

THE COMPLETE PATTERN
--------------------
Markup:

    <au:AjaxFileUpload ID="Uploader1" runat="server"
        AutoPostBack="true"
        OnFileUploaded="Uploader1_FileUploaded" />

Code-behind (or <script runat="server">):

    protected void Uploader1_FileUploaded(object sender,
        AjaxUploader.Events.FileUploadedEventArgs e)
    {
        // Never build the destination from the client's file name alone -
        // it is attacker-controlled text. Keep only the extension.
        var savedName = Guid.NewGuid().ToString("N") +
                        System.IO.Path.GetExtension(e.FileName ?? "");

        new AjaxUploader.Services.UploadService()
            .CopyFile(e.FileGuid, "~/uploads/" + savedName);
    }

That is the whole story. See it running: DemoApp > Basic Upload > Single File.

WHEN DOES FileUploaded RUN?
---------------------------
On the next Web Forms POSTBACK - not during the transfer. Three ways to get one:

  1. AutoPostBack="true" on the control (shown above). The page posts back
     automatically when the whole batch finishes. This matches the v4
     (CuteWebUI) behaviour. Use it when the page has no submit flow of its own.
  2. A normal <asp:Button>. The event fires when the user submits - the right
     choice when uploads are part of a larger form.
  3. Your own __doPostBack call from OnClientQueueComplete-style JS.

If the handler never seems to run: no postback is happening. That is the #1
support case for "upload succeeds but nothing is saved".

DESTINATION PATHS
-----------------
CopyFile / MoveFile accept:
  - App-relative:  "~/uploads/file.jpg"   (resolved against the site root)
  - Absolute:      "D:\\data\\uploads\\file.jpg"
  - Bare relative: "uploads/file.jpg"     (also anchored at the site root)

CopyFile keeps the temp copy (swept later); MoveFile removes it immediately.

IF IT STILL DOES NOT SAVE
-------------------------
Copy DemoApp\SaveDiagnostic.aspx into your site root, upload a file, click the
STEP 2 button. It prints, separately: which DLL is loaded (and its build date),
where the temp folder resolves, what the browser posted back, whether the event
fired, and the exact exception if the copy failed. Whichever line is wrong
names your problem.

Common causes, in order:
  1. Old AjaxUploader.dll still loaded  -> replace bin DLL, RECYCLE THE APP POOL
  2. No postback (see above)            -> AutoPostBack or a submit button
  3. App pool identity cannot write     -> grant write on the destination folder
  4. Handler throws                     -> the diagnostic prints the exception
