what is uploadify?
This plugin allows you to change any element with an ID on your page into a single or multiple file upload tool. The plugin uses a mix of JQuery, Flash, and a backend upload script of your choice to send files from your local computer to your website server.
The secret to Uploadify lies in the communication between Flash and JavaScript. Two key elements in ActionScript 3 make this possible - FileReference and ExternalInterface. FileReference handles the upload process while ExternalInterface is used to transfer information between the Flash element and JavaScript on the page. ExternalInterface also makes it possible to trigger functions across the two.
JQuery was used as the JavaScript framework because it makes the implementation very simple.
requirements
- jQuery v1.2.x
preparation
- Download the jquery.uploadify-v1.6.2.zip package
- Unzip the file and upload the contents to your website
Example
Let's take simplest form,
CSS
.fileUploadQueueItem { font: 11px Verdana, Geneva, sans-serif; background-color: #F5F5F5; border: 3px solid #E5E5E5; margin-top: 5px; padding: 10px; width: 300px; }
.fileUploadQueueItem .cancel { float: right; }
.fileUploadProgress {
background-color: #FFFFFF;
border-top: 1px solid #808080;
border-left: 1px solid #808080;
border-right: 1px solid #C5C5C5;
border-bottom: 1px solid #C5C 5C5;
margin-top: 10px;
width: 100%; }
.fileUploadProgressBar {
background-color: #0099FF;
}
Add these reference to the head part of your web page,
$(document).ready(function() { $("#fileUpload").fileUpload({ 'uploader': 'uploader.swf', 'cancelImg': 'cancel.png', 'script': 'upload.php', 'folder': 'files', 'multi': false, 'displayData': 'speed' }); $("#fileUpload2").fileUpload({ 'uploader': 'uploader.swf', 'cancelImg': 'cancel.png', 'script': 'about_upload.php', 'folder': 'About_images', 'multi': true, 'buttonText': 'Select Files', 'checkScript': 'check.php', 'displayData': 'speed', 'simUploadLimit': 2 }); $("#fileUpload3").fileUpload({ 'uploader': 'uploader.swf', 'cancelImg': 'cancel.png', 'script': 'upload.php', 'folder': 'files', 'fileDesc': 'Image Files', 'fileExt': '*.jpg;*.jpeg;*.gif;*.png', 'multi': true, 'auto': true }); });
Then the upload script , which can be use any script language ,here i use php.
if (!empty($_FILES)) {
$tempFile = $_FILES['Filedata']['tmp_name']; $targetPath = $_SERVER['DOCUMENT_ROOT'] . $_GET['folder'] . '/';
$targetFile = str_replace('//','/',$targetPath) . $_FILES['Filedata']['name'];
mkdir(str_replace('//','/',$targetPath), 0755, true); move_uploaded _file($tempFile,$targetFile); }
?>
This plug in integrate with Flash component as well. So final solution look like this
Demo:http://www.uploadify.com/demo/
Enjoy with Jquery........................
