Monday, March 23, 2009

Easy File Upload by Using JQueryUploadify Plugin

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

  1. Download the jquery.uploadify-v1.6.2.zip package
  2. 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,




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........................

Sunday, March 15, 2009

Cool Relection Effect Using JQuery Reflection Plugin

Introduction

This is an improved version of the reflection.js script rewritten for the jQuery javascript library. It allows you to add instantaneous reflection effects to your images in modern browsers, in less than 2 KB.

Features

Compared to the original reflection.js, this script has the following added features:

* The reflections appear instantly under each image as soon as it completes loading, instead of having to wait for all images of the page to be loaded before seeing all reflections being applied at the same time. This provides a much better user experience.
* The code is smaller than the original reflection.js and has been optimized for jQuery. If you are already using jQuery, you will gain a few kilobytes.
* The code has a few bugfixes that the original script doesn’t have. It usually works better.

Performance

Like the original reflection.js, this script is much faster than the script.aculo.us Reflector script (which is not suited for production use), because it does not create a large number of image zones (one for each pixel line). Instead, it uses the canvas tag available in most modern browsers, and DirectX image transformation filters in Internet Explorer, so the reflection image is drawn natively in one step.


Compatibility

This script works in all browsers supporting the canvas tag: Firefox 1.5+, Opera 9+, Safari 2+, Camino and Google Chrome. It also works in Internet Explorer 6+ by using an alternative drawing technique.

In older browsers, the script will degrade automatically (the images will remain untouched).

WARNING
Firefox 2.0.0.10 broke the canvas.drawImage() javascript function and therefore this particular version does not work with this script. Firefox 2.0.0.11 and more recent will work.

It works with all image formats, but reflections of animated GIFs will not be animated: the first frame will be used for the reflection. There is no way to make a dynamic animated reflection for GIF images using javascript.


Requirements

Reflection.js for jQuery (obviously) requires the jQuery library, version 1.2.3 or more recent.
Usage
Setup

Just include the script in the header of your page, after the inclusion of the jQuery library:



Adding reflections

Reflections can be added to any image tag over any kind of background (even image backgrounds!). There are two ways of adding a reflection:

1) Using HTML, by applying a CSS class named “reflect” to your images:


This will use the default reflection parameters (see below). You can apply multiple classes to an image (separated by spaces), the script will detect if “reflect” is one of them.

2) Using javascript, by calling the reflect() method on a jQuery selector. Examples:

$("#photo1").reflect(options);

or

$("#gallery img").reflect(options);

“options” is an optional argument similar to the other options arguments in jQuery. The following options are available:

* height: The height of the reflection, proportionally to the image height (range: 0 to 1). Default is 1/3.
* opacity: The starting opacity of the reflection (range: 0 to 1). The reflection is shown as an opacity gradient going from this value to 0. Default is 1/2.

If you call this method more than once for the same image, the previous reflection will be automatically replaced by the new one.

Important: If you use javascript to add the reflection effect, you can call these methods either as soon as the DOM is ready (using the jQuery function) or by placing the call directly in a javascript block below the image you want to reflect. You don’t need to delay the call after the window “load” event. Your images will appear reflected as soon as they complete loading, even if they were not fully loaded when the javascript method was called. This is the main difference between this script and the original reflection.js.
Removing reflections

You can remove a reflection using javascript, by calling the unreflect() method on a jQuery selector. Example:

$("#photo1").unreflect();

CSS limitations

When adding the reflection effect, the script wraps the image inside a
block and adds the reflection to the same block, just below the original image. The class and style attributes of the image will be set blank and applied to the div instead, so the whole block will show like the original image. This operation is reverted when removing the reflection.

This means that you can style the mirrored images using CSS classes and using their style attribute, but you can not style the img tag directly.

For example, when reflected, the following image will not display properly because it is using a CSS rule mentioning the img tag:

CSS:

#content img {
float: left;
margin: 20px;
}

HTML:


Instead, you must use a CSS class without referring to the img tag (or use the style attribute) and it will display like expected:

CSS:

#content .leftimage {
float: left;
margin: 20px;
}

HTML:


Also, the reflection will display properly with block-style images, but not with inline-style images. If you apply it to an inline-style image, it will be transformed to a block-style image. Most websites use only block-style images, so it should not be a problem.

Finally, you must not specify the height of the reflected image using a CSS class or style property, because the height will increase when the reflection will be applied. Set the width and height attributes on the tag instead if you want to (it’s optional).

Demo:http://getintothis.com/pub/projects/gallery/