Aurigma Image Uploader 4.8 Dual
Uploading Non-Image Files
See Also

Notwithstanding Image Uploader's name, it can be used not only to upload images. It can work with any kind of files, including (but not limited to):

- Documents
- Music
- Archives
- ...

# General Settings

To upload non-image files you should configure the FileMask property as discussed in the Restricting Files by Extensions and Types topic.

A good idea is to set a view mode of Image Uploader panes from thubmnails to a simple or detailed list. You can do this with a help of the FolderView and UploadView properties.

This code example demonstrates how to do this:

JavaScript | Copy Code
--- | ---
    <script type="text/javascript" src="iuembed.js"></script>

    <script type="text/javascript">
    var iu = new ImageUploaderWriter("ImageUploader", 710, 500);

    //...Any other params...

    iu.addParam("FileMask", "*.*");

    iu.addParam("FolderView", "List");
    iu.addParam("UploadView", "List");

    //...

    iu.writeHtml();
    </script>

# Uploading Mixed Content

Sometimes it may be useful to let your users upload mixed content, for example when you develop a multimedia gallery that supports not only image files but also audio or video. If this is the case and you also do not want to upload large images (that is the images should be resized to some dimensions), you encounter a problem. Normally, when uploading only images, you would turn off upload of source files as you do not need too large images, and upload only thumbnails of the required dimensions. But if you let the users upload non-image files, such files won't be sent at all in this situation.

To solve this problem, you can do the following (regards the client side):

1. Disable uploading the source files setting the UploadSourceFile property to false.
2. Make Image Uploader upload the thumbnails of the images using the Fit mode, as you want only resized images.
3. Set the fallback mode so that if the thumbnails cannot be created, the original files are sent to the server.

Here is how it should look like:

JavaScript | Copy Code
--- | ---
    <script type="text/javascript" src="iuembed.js"></script>

    <script type="text/javascript">
    var iu = new ImageUploaderWriter("ImageUploader", 710, 500);

    //...Any other params...

    //Disable upload of the original files
    iu.addParam("UploadSourceFile", "false");

    //Set up thumbnail upload
    iu.addParam("UploadThumbnail1FitMode", "Fit");
    iu.addParam("UploadThumbnail1Width", "1024");
    iu.addParam("UploadThumbnail1Height", "768");
    iu.addParam("UploadThumbnail1FallbackMode", "SourceFile");

    //...

    iu.writeHtml();
    </script>

Then, on the server side you need to add a switch like the following to your script that handles upload (for brevity only the C# listing is provided, but you should get the idea):

C# | Copy Code
--- | ---
    //...Other code...

    //Iterate through all thumbnails
    int fileCount = Int32.Parse(Request.Form["FileCount"]);
    for (int i = 1; i <= fileCount; i++)
    {
        //Get the thumbnail file which contains either the source file or the
        //thumbnail
        HttpPostedFile thumbnail1File = Request.Files["Thumbnail1_" + i];
        //Check if the first thumbnail was created
        if (Request.Form["Thumbnail1Succeeded_" + i] == "true")
        {
            //...Process thumbnail1File as an image file...
        }
        else
        {
            //...Process thumbnail1File as a non-image file...
        }
    }

    //...Other code...

# See Also

##### Reference

FileMask Property
UploadSourceFile Property

##### Manual

Restricting Files by Extensions and Types