Getting Started

Aurigma Up is a mobile app available for iPhone, iPad, and Android devices which allows your users to easily upload files to your website and provides far superior capabilities in an extremely feature-rich package.

Let's see how it works from the user's perspective.

Users open the upload page on your website in the mobile browser, …

… launch Aurigma Up by tapping the Upload button,

… add photos/videos to the upload list,

… start the Upload with a single touch,

… automatically return to your site upon upload completion.

As you see, from the development point of view, you only need to do two things: create an HTML button which will open Aurigma Up with proper settings and the simple server-side code which will save photos on your server.

Inserting the Upload button to your page

This part is extremely simple - you just need to insert one lengthy line of code, using the <a href> tag. This tag refers to a URL that is based on the purpose-built aurup protocol.

The line looks like this:

<a href="aurup:?uploadUrl=http://domain.com/upload&redirectUrl=http://domain.com/gallery">    
    Upload Images    
</a>

As can you see, it has the query string with attributes that configure Aurigma Up. You can use Aurigma Up Code Designer to generate the code with all necessary attributes automatically. Not all attributes are compulsory, however, you should always specify these three:

  • uploadUrl — the target page to which Aurigma Up sends the photos. We will explain how to create this page in the next section.
  • redirectUrl — the page to which Aurigma Up will return the user when the upload is completed. It can be the same page or the photo gallery page – whichever you want.
  • licenseKey — you can either receive free license key (with limited features), request 30-day trial or purchase a full version.

Tip

Be sure to include a notice on the page that users should install the Aurigma Up app on their iPhone or Android from iTunes or Google Play using the appropriate link:

Saving the uploaded photos/videos on your server

To save the uploaded photos and videos on your server, you need to create a simple server-side script, and specify its URL in the uploadUrl attribute as described above. This script will accept the POST request sent by Aurigma Up. In this script you will refer to the uploaded photos using the POST variable names as described in the POST API reference and simply save them to the desired folder on your server.

This script can be created no matter what server platform you use - PHP, ASP.NET, JSP or anything else. Keep in mind, regardless of your server preference, this script will take several lines.

Let's review some simple PHP and ASP.NET code examples.

PHP

<?php   
$path = realpath('./gallery/') . DIRECTORY_SEPARATOR;    
    
$fileCount = $_POST["PackageFileCount"];    
    
for ($i = 0; $i < $fileCount; $i++) {    
    if (isset($_FILES['File0_' . $i])) {    
        move_uploaded_file($_FILES['File0_' . $i]['tmp_name'],     
                           $path . $_POST['SourceName_' . $i]);    
    }    
}   
?>

ASP.NET

private void Page_Load(object sender, EventArgs e)    
{    
    int fileCount = Int32.Parse(Request.Form["PackageFileCount"]);    
    
    for ( int i = 0; i < fileCount; i++ )    
    {    
        string path = System.IO.Path.Combine(    
                                Server.MapPath("./gallery/"),     
                                Request.Form["SourceName_" + i]);    
    
        Request.Files["File0_" + i].SaveAs(path);    
    }    
}

As you can see here, Aurigma Up sends the following POST fields:

  • PackageFileCount - how many files are being uploaded.
  • File0_0, File0_1, ..., File0_N — files themselves.
  • SourceName_0, SourceName_1, ..., SourceName_N — file names.

To access to the POST request, in PHP you use $_FILES and $_POST "superglobals", while in ASP.NET you use the intrinsic Request object.


Note: It also sends some additional POST variables. You can find a full list on the Server-side API

Configuring Image Resizing

By default, Aurigma Up sends original files. However it is possible to configure it to create thumbnails and upload them instead or along with original files.

To do it, use imageMode parameter of the aurup upload link. The imageMode parameter accepts a key=value string, where key-value pairs are separated by commas.

Uploading only resized copy

To upload only thumbnails you should set the image mode to thumbnail and required size, as follows:

aurup:?imageMode=mode=thumbnail,size=480

Uploading both thumbnail and original image

To send an original file + several thumbnails, just specify several sets of parameters separated by semicolons, for example:

imageMode=mode=source;mode=thumbnail,size=2048;mode=thumbnail,size=120

This configuration tells Aurigma Up to send a copy of original image and two resized copies for each image selected to upload — a 120×120 thumbnail and a hi-res 2048×2048 copy.


Hint: you can find more detailed description of possible imageMode values on the Code Designer page

Saving images on the server

Now let's modify our server code to save not just the original file, but all resized copies. Let's use /gallery/thumbnails for and 120×120 thumbnails and for /gallery/large for large copies. To do it, we should handle not just File0_i, but also File1_i (thumbnails) and File2_i (large copies).

PHP

<?php   
$galleryPath = "gallery";   
$absGalleryPath = realpath($galleryPath);   
$absThumbnailsPath = realpath($galleryPath . DIRECTORY_SEPARATOR . "thumbnails");   
$absLargePath = realpath($galleryPath . DIRECTORY_SEPARATOR . "large");   
   
//Get number of files in the current package.   
$fileCount = $_POST["PackageFileCount"];   
   
//Iterate through uploaded data and save the original file and thumbnail.   
for ($i = 0; $i < $fileCount; $i++) {   
       
    $originalFileName = rawurlencode($_POST["SourceName_" . $i]);   
       
    //save copy of original image   
    if (isset($_FILES["File0_" . $i])) {   
        move_uploaded_file($_FILES["File0_" . $i]["tmp_name"],    
            $absGalleryPath . DIRECTORY_SEPARATOR . $originalFileName);   
    }   
   
    //save thumbnail   
    if (isset($_FILES["File1_" . $i])) {   
        move_uploaded_file($_FILES["File1_" . $i]["tmp_name"],    
            $absThumbnailsPath . DIRECTORY_SEPARATOR . $originalFileName);   
    }   
   
   //save large copies   
    if (isset($_FILES["File2_" . $i])) {   
        move_uploaded_file($_FILES["File2_" . $i]["tmp_name"],    
            $absLargePath . DIRECTORY_SEPARATOR . $originalFileName);   
    }   
}   
?>

ASP.NET

private void Page_Load(System.Object sender, System.EventArgs e)   
{   
    if (System.String.Equals(Request.RequestType, "POST"))   
    {   
        string galleryPath = Server.MapPath("Gallery/");   
        string thumbnailsPath = galleryPath + "Thumbnails/";   
        string largePath = galleryPath + "Large/";   
   
        int fileCount = int.Parse(Request["PackageFileCount"]);   
        for (int i = 0; i < fileCount; i++)   
        {   
            string originalFileName = Request["SourceName_" + i];   
   
            // save original file   
            HttpPostedFile sourceFile = Request.Files["File0_" + i];   
            if (sourceFile != null)   
            {   
                sourceFile.SaveAs(System.IO.Path.Combine(galleryPath, originalFileName));   
            }   
   
            // save thumbnail   
            HttpPostedFile thumbnailFile = Request.Files["File1_" + i];   
            if (thumbnailFile != null)   
            {   
                thumbnailFile.SaveAs(System.IO.Path.Combine(thumbnailsPath, originalFileName));   
            }   
   
            // save large copies   
            HttpPostedFile largeFile = Request.Files["File2_" + i];   
            if (largeFile != null)   
            {   
                largeFile.SaveAs(System.IO.Path.Combine(largePath, originalFileName));   
            }   
        }   
    }   
}