Server side adapters are designed to extend the functionality of the Flajaxian FileUploader web control. The control comes with two adapters:

  1. FileSaverAdapter - used for saving the files in a folder on the server.

    Here is an example of how you can use it:

    <fjx:FileUploader ID="FileUploader1" runat="server" >
        <Adapters>
            <fjx:FileSaverAdapter Runat="server" FolderName="UploadFolder" />
        </Adapters>
    </fjx:FileUploader>
    

    In this example file will be uploaded on the folder UploadFolder

  2. ThumbGeneratorAdapter - used to generate thumbnails for the image files.

    Here is an example of how you can use it:

    <fjx:FileUploader ID="FileUploader1" runat="server" >
        <Adapters>
            <fjx:ThumbGeneratorAdapter Runat="server" 
                Extensions="jpg;jpeg" FolderName="UploadFolder" 
                Suffix="_thumb" MaximumWidth="200" MaximumHeight="200" />
        </Adapters>
    </fjx:FileUploader>
    

    In this example the templates will be generated in a folder UploadFolder with suffix _thumb for the files with extension jpeg or jpg. The thumbnails will be withing the frame of 200 pixels height and width.


    You can use more than one adapter. They will be executed in the order of their definition. For example:

    <fjx:FileUploader ID="FileUploader1" runat="server" >
        <Adapters>
            <fjx:FileSaverAdapter Runat="server" FolderName="UploadFolder" />    
            <fjx:ThumbGeneratorAdapter Runat="server" 
                Extensions="jpg;jpeg" FolderName="UploadFolder" 
                Suffix="_thumb" MaximumWidth="200" MaximumHeight="200" />
        </Adapters>
    </fjx:FileUploader>
    

Custom Adapters

You can create your own adapter. They must extend com.flajaxian.FileUploaderAdapter. This is a simple tamplate you can use to create your own server side adapter:

using System;
using System.Web;
using System.Collections;

namespace CustomNamespace
{

    public class CustomAdapter : FileUploaderAdapter
    {
        /// <param name="file">Incoming file</param>
        /// <param name="state">
        /// Hashtable that can be used to transfer a state between different adapters. 
        /// This file is not used for this adapter.
        /// </param>
        public override void ProcessFile(HttpPostedFile file, Hashtable state)
        {
            // process the file here
        }

    }
}