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.
Let's make some preparations first.
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>
<?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.
<?php require_once "ImageUploaderFlashPHP/UploadHandler.class.php"; $uploadHandler = new UploadHandler(); $uploadHandler->saveFiles("Catalog/"); ?>
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 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.