## Aurigma Image Uploader Flash 1.0

# Quick Start with Embedding Scripts Library

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

Image Uploader Flash embedding scripts library is a set of JavaScript classes intended to embed Image Uploader Flash into a web page via <script type="text/javascript"> block. This JavaScript (aurigma.imageuploaderflash.js) is a base for both Image Uploader Flash ASP.NET control and PHP library. Using the JavaScript library is more complicated: it requires configuring Image Uploader Flash parameters manually and does not provide facilities to handle uploaded data server-side. However, it is more flexible and can be used with any HTTP-compliant server platform (not only ASP.NET or PHP).

## Adding Image Uploader Flash to Page

To add Image Uploader Flash to the page you just need to perform the following steps:

1. Copy the /ClientScripts folder to your web application. It can be found in Image Uploader Flash installation folder (typically this is C:\Program Files\Aurigma\Image Uploader Flash 1.0).

2. Link the aurigma.imageuploaderflash.js file with the page which will host Image Uploader Flash.

   ### JavaScript

       <script type="text/javascript" src="../ClientScripts/aurigma.imageuploaderflash.js"></script>

3. Add JavaScript block to the position where you want to insert Image Uploader Flash. Here create a new instance of the imageUploaderFlash class and specify mandatory parameters such as imageUploaderFlash.id and flashControl.codeBase.

   ### JavaScript

       <script type="text/javascript">
           var fu = $au.imageUploaderFlash({
               id: 'Uploader1',
               flashControl: {codeBase: '../ClientScripts/aurigma.imageuploaderflash.swf'}
           });

           // configure Flash Uploader

           fu.writeHtml();
       </script>

4. Then configure it in the way described in the following sections and call the writeHtml() method.

   Note:

   As soon as you call the imageUploaderFlash.writeHtml(), all necessary HTML code is inserted into the page at the current position. Alternatively, you can get the string with appropriate HTML code using the imageUploaderFlash.getHtml() method, and write it to the necessary position manually (maybe with some modifications).

## Uploading Files

Here we discuss how to use Image Uploader Flash embedding scripts library by the example of a simple file catalog. Suppose that the catalog requires a user to upload files of various types and displays links to download these files. To implement this we should configure an imageUploaderFlash object and save uploaded files on a server. The sections below describe these steps in detail.

### Configuring

To configure Image Uploader Flash you should set properties of the imageUploaderFlash object. See the Image Uploader Flash Embedding Scripts Library Reference for the detailed information about available properties.

The properties accepting objects (such us upload or converters) should be specified in JSON format. Using this format you can also initialize all the imageUploaderFlash properties when creating it. Alternatively, you can use the imageUploaderFlash.set(Object) method which accepts a JSON formatted string containing one or several properties definition.

Here is the source code of the main page of our catalog:

### JavaScript

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>Embedding Scripts Library Sample</title>
    </head>
    <body>
        <script type="text/javascript" src="../ClientScripts/aurigma.imageuploaderflash.js">  </script>
        <script type="text/javascript">
            $au.imageUploaderFlash({
                id: 'Uploader1',
                width: '650px',
                height: '480px',
                licenseKey: 'XXXXX-XXXXX-XXXXX-XXXXX-XXXXX',
                flashControl: {
                    codeBase: '../ClientScripts/aurigma.imageuploaderflash.swf'
                },
                converters: [
                    { mode: '*.*=SourceFile' }
                ],
                upload: {
                    actionUrl: 'upload.aspx',
                    redirectUrl: 'gallery.aspx'
                }
            });

            $au.imageUploaderFlash('Uploader1').writeHtml();
        </script>
    </body>
    </html>

On this page we set mandatory parameters, such as Image Uploader Flash identifier and path to the aurigma.imageuploaderflash.swf file, as well as optional parameters required by our file catalog. Here we specify server upload script and a page to which a user will be redirected when the upload successfully completes. To configure Image Uploader Flash to send original files we used the imageUploaderFlash.converters property which accepts an array of converter objects. Each object specifies what will be uploaded (original file as is, thumbnail created from original image file, icon associated with original file, or original file compressed into ZIP archive) for each of the user-selected files. Since we need to upload original files only, we set a one converter with the SourceFile mode. Read more about converters in the Configuring Upload Settings topic.

One more significant property is imageUploaderFlash.licenseKey which specifies trial or full license key. If license key is not set Image Uploader Flash will not send files (the exception is usage of uploader on localhost domain). See the How to Register Evaluation and Production License Keys topic for details.

### Handling Upload

According to the catalog requirements we save original files to the /Catalog folder. The way to implement it depends on your server platform. Find the detailed instructions and code samples on how to save uploaded files in ASP.NET and PHP in the Saving Uploaded Files in ASP.NET and Saving Uploaded Files in PHP articles respectively.

### Displaying Uploaded Files

On the configuring step we set the upload.redirectUrl property. It specifies a page to which Image Uploader Flash will redirect users after the upload successfully completes. So, it would be convenient to list links to the uploaded files here. To implement this functionality we iterate through all the files stored in the /Catalog folder and display a link to each of them.

The script which generates this page depends on your server platform. For example, if you save uploaded files in ASP.NET, you can use the script listed in the Quick Start with ASP.NET Control topic. For PHP platform use the analogue from the Quick Start with PHP Library article.

## Uploading Images

One more example of Image Uploader Flash usage is an image gallery. Suppose, it requires a user to upload original images along with their downsized copies. This task can be divided into the same phases as the previous one.

### Configuring

The configuration of the imageUploaderFlash object used for our image gallery is almost the same as for the file catalog described above.

### JavaScript

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>Embedding Scripts Library Sample</title>
    </head>
    <body>
        <script type="text/javascript" src="../ClientScripts/aurigma.imageuploaderflash.js">  </script>
        <script type="text/javascript">
            $au.imageUploaderFlash({
                id: 'Uploader1',
                width: '650px',
                height: '480px',
                licenseKey: 'XXXXX-XXXXX-XXXXX-XXXXX-XXXXX',
                flashControl: {
                    codeBase: '../ClientScripts/aurigma.imageuploaderflash.swf'
                },
                converters: [
                    { mode: '*.*=SourceFile' },
                    { mode: '*.*=Thumbnail;*.*=Icon', thumbnailFitMode: 'Fit', thumbnailWidth: '120', thumbnailHeight: '120' }
                ],
                upload: {
                    actionUrl: 'upload.aspx',
                    redirectUrl: 'gallery.aspx'
                }
            });

            $au.imageUploaderFlash('Uploader1').writeHtml();
        </script>
    </body>
    </html>

The difference is that we set an additional converter to specify a thumbnail which will be created for each image file and will be fitted to 120x120 pixels. For non-image files this converter will send icons. Read more about converters in the Configuring Upload Settings topic.

### Handling Upload

The gallery stores original images and their thumbnails in /Gallery and /Gallery/Thumbnails folders respectively. The way to implement it depends on your server platform. Find the detailed instructions and code samples on how to save uploaded files in ASP.NET and PHP in the Saving Uploaded Files in ASP.NET and Saving Uploaded Files in PHP articles respectively.

### Displaying Uploaded Files

On the configuring step we set the upload.redirectUrl property. It specifies a page to which Image Uploader Flash will redirect users after the upload successfully completes. So, it would be convenient to display uploaded files here. To implement this functionality we iterate through all the previews stored in the /Gallery/Thumbnails folder and display each thumbnail as a link to its original image (original images are stored in the /Gallery folder).

The script which generates this page depends on your server platform. For example, if you save uploaded files in ASP.NET, you can use the script listed in the Quick Start with ASP.NET Control topic. For PHP platform use the analogue from the Quick Start with PHP Library article.

## See Also

### Reference

- Image Uploader Flash Embedding Scripts Library Reference
- imageUploaderFlash Class

### Manual

- Configuring Upload Settings
- How to Register Evaluation and Production License Keys
- Saving Uploaded Files in ASP.NET
- Saving Uploaded Files in PHP