## Aurigma Image Uploader 7.0.15

# Handling Upload Completion

- Collapse All Sections
- See Also
- Language Filter ( all languages )

When a user uploads files using a standard <input type="file"> element, they expect to be redirected to the page they have submitted files to. However, Image Uploader works in a different way. The response generated by the page, which is specified with the UploadSettings.ActionUrl property, is sent back to Image Uploader rather than to the browser. In other words, it works as follows:

1. Image Uploader submits files to the server using POST requests.
2. The server script specified with the ActionUrl property processes uploaded files and sends some HTML back to Image Uploader.
3. As soon as Image Uploader receives the response, the upload is considered completed. Now, the response should be handled somehow.

What will actually happen on the last step depends on you. First of all, no action can be taken. This is convenient when Image Uploader is inserted into a pop-up window and you would like to have it opened in the background.

Another popular behavior is to redirect a user to another page which, for example, displays uploaded files. The simplest way to accomplish this is to use the UploadSettings.RedirectUrl property:

### ASP.NET

    <aur:Uploader ID="Uploader1" runat="server">
        <UploadSettings ActionUrl="upload.aspx"
            RedirectUrl="gallery.aspx" />
    </aur:Uploader>

### PHP

    $uploader = new Uploader("Uploader1");
    $uploader->getUploadSettings()->setActionUrl("upload.php");
    $uploader->getUploadSettings()->setRedirectUrl("gallery.php");

### JavaScript

    var u = $au.uploader({
        id: 'Uploader1',
        uploadSettings: { actionUrl: 'upload.aspx', redirectUrl: 'gallery.aspx' }
    });

A more complicated, but more flexible way of handling the server response is to use the AfterUpload event. It is raised upon successful upload, and with it you can perform any actions allowed in client-side scripting. For example, you may specify another way of redirecting a user:

### JavaScript

    function afterUploadHandler(response) {
        window.location = "gallery.aspx";
    }

    var u = $au.uploader({
        id: 'Uploader1',
        events: { afterUpload: afterUploadHandler }
    });

Or you can get access to the server response returned from the upload processing script. Here we demonstrate how to display a page returned from a server:

### JavaScript

    function afterUploadHandler(response) {
        var newWindow = window.open();
        with (newWindow.document) {
            open("text/html");
            write(response);
            close();
        }
    }

    var u = $au.uploader({
        id: 'Uploader1',
        events: { afterUpload: afterUploadHandler }
    });

## See Also

### Reference

- ActionUrl Property
- RedirectUrl Property
- AfterUpload Event

- ActionUrl (ASP.NET)
- ActionUrl (PHP)
- actionUrl (JavaScript)

- ActionUrl (ASP.NET)
- ActionUrl (PHP)
- actionUrl (JavaScript)

- RedirectUrl (ASP.NET)
- RedirectUrl (PHP)
- redirectUrl (JavaScript)

- ActionUrl (ASP.NET)
- ActionUrl (PHP)
- actionUrl (JavaScript)

- RedirectUrl (ASP.NET)
- RedirectUrl (PHP)
- redirectUrl (JavaScript)