Getting started with Aurigma

Upload Suite contains out-of-the box client-side applications based on various technologies, which let it to work with all major platforms (Windows, Mac, Linux) and in all the most popular browsers (IE, Mozilla, Safari, Google Chrome).

Upload Suite includes two uploaders - a lightweight HTML5/Flash Uploader and more advanced ActiveX/Java Uploader. Let's see how to integrate one of them into your PHP project. We will use HTML5/Flash-based uploader as an example, but you can also add Java/ActiveX Uploader in the same manner.

There are two API can be used in PHP to deal with Upload Suite - PHP library and JavaScript library. In this article we will see how to use PHP library, but if you prefer using JavaScript API directly, check out instructions for other server technologies.

Before we start

Let's make some preparations first.

  1. Download and install the free trial from Aurigma’s website.
  2. Copy the ImageUploaderPHP folder to your application. You can find the library in the Upload Suite installation folder (usually this is C:\Program Files (x86)\Aurigma\Upload Suite [version number]\HTML5-Flash\).
  3. Configure php.ini to set max POST request length and file size limitations. See Configuring PHP for uploads for more details.
  4. Make sure that the folder where you save files has enough permissions.

Inserting HTML5/Flash Uploader

Now we are ready to insert the uploader to a page.

First, link the ImageUploaderFlash.class.php file with the webpage and call the renderCssRules() static method in the head section of the page:

<head>           
    <?php           
      require_once 'ImageUploaderFlashPHP/ImageUploaderFlash.class.php';           
      ImageUploaderFlash::renderCssRules();           
    ?>           
</head>

Now, create a new instance of the ImageUploaderFlash class and call the render() method in the position you want to insert Uploader into:

<?php           
    $uploader = new ImageUploaderFlash("Uploader1");           
           
    //configure HTML5/Flash Uploader           
           
    $uploader->render();           
?>

Now you can configure the uploader using special methods of the ImageUploaderFlash. The full code of the client-side part may look as follows (index.php):

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">          
<html>          
<head>          
    <title>PHP Upload Sample</title>          
    <?php          
      require_once 'ImageUploaderFlashPHP/ImageUploaderFlash.class.php';          
      ImageUploaderFlash::renderCssRules();          
    ?>          
</head>          
<body>          
    <?php           
        // create ImageUploaderFlash object and specify its ID and size          
        $uploader = new ImageUploaderFlash("Uploader1");          
        $uploader->setWidth("650px");          
        $uploader->setHeight("480px");          
                  
        // specify a license key          
        $uploader->setLicenseKey("XXXXX-XXXXX-XXXXX-XXXXX-XXXXX-XXXXXX");          
          
        // configure upload settings          
        $uploader->getUploadSettings()->setActionUrl("upload.php");          
          
        // render ImageUploaderFlash          
        $uploader->render();          
    ?>          
</body>          
</html>

As you can see, it also has the Action, just like the simple HTML form. It points out to the upload.php script that will receive the uploaded files.


Note:LicenseKey property should specify a trial or full license key. This property is always required except cases when you run your website on the localhost.

Saving the uploaded on a server

The server-side script implemented in the upload.php may be very simple: you just call the saveFiles method of UploadHandler to save all files to a particular folder:

<?php          
require_once "ImageUploaderFlashPHP/UploadHandler.class.php";          
          
$uploadHandler = new UploadHandler();          
$uploadHandler->saveFiles("Catalog/");          
?>

Result

Now run the index.php page in a browser. You will see a simple upload interface (pure HTML5 or Flash, depending on the browser):

Aurigma HTML5 uploader for PHP.

What's Next?

Aurigma Uploader Suite allows you to configure the uploader very flexibly, customize the user interface, pre-process images before the upload (resize, crop, watermark), filter files, split large files before the upload, etc. You can find a lot of examples in the Upload Suite SDK package.

If you would like to get more knowledge about Aurigma’s Uploader Suite you can read the documentation or contact our support team.