Plugins Directory

If you want to become a plugin author or manage your plugins log in at our forums!

SWFupload 0.2.1

Rate this Plugin!

Average rating: 4 | Please login at our forums to rate this plugin!



This plugin allows uploading files using the SWFUpload JavaScript/Flash library. You can easily convert your existing input fields into 'swf upload fields'.

This plugin allows uploading files using the SWFUpload JavaScript/Flash library. You can easily convert your existing input fields into 'swf upload fields'. SWFUpload offers many configuration settings to limit all kind of file parameters (size,type,number,..) and leaves the UI to the browser.

« DEMO »

changelog

2008-04-11 vers 0.2.1
  • fixed bug were response wasn't processed in IE
2008-04-10 vers 0.2
  • changed base class to xajaxResponsePlugin
  • added response function to transform forms/fields via xajax
  • added destroy function to unload swf movie and containers
  • added response functions for destroying fields/forms
  • added callback events
  • added config parameter 'multiple'
  • added compressed JS files
  • fixed bug in upload rate
  • fixed bug where xajax request wasn't send when queue was empty
2008-04-07 vers 0.1
  • first release

supported configurations

  • PHP 5.x
  • any webserver
  • Flash 9
  • Xajax 0.5

install

Just copy the "swfupload" folder into your xajax install below /xajax/xajax_plugins/request/.
If you have downloaded the full package just replace your old xajax install with the provided xajax folder. Do not copy the new folder into the old one!

usage

configuration function registration JavaScript functions response functions include the plugin right after the xajax object instantiation and before configuring xajax.

Code: php

$xajax = new xajax();
require_once './xajax/xajax_plugins/request/swfupload/swfupload.inc.php';
$xajax->configure("javascript URI","/swfupload/xajax/");

function registration

You can turn any xajax enabled function into an upload function by setting the mode to 'SWFupload':

Code: php

$xajax->register(
 XAJAX_FUNCTION,
 "my_upload_function",
 array("mode" => "'SWFupload'", "SWFfield" => 'my_field_id',"SWFform" => 'my_form_id')
);

The "mode" is required to enable file uploading via SWF. Both other parameters are optional. When setting for instance "SWFfield" => 'field_id' it will only upload the file queue of the given field. The same applies for "SWFform" => 'my_form_id', with the exception that it will upload all queues from all file inputs inside the given form.

You can only set either SWFform or SWFfield. Without setting one of these values the function will upload all files from all queues! To trigger the upload you only have to call the generated xajax function stub (xajax_ + function name). You can even pass additional values:

Code: php

 
 

Javascript functions

The plugin provides two helper functions that will turn any file input fields into 'flash upload fields'.
  • xajax.ext.SWFupload.tools.transForm(form_id [String], config [optional Object], multiple [bool optional])
  • xajax.ext.SWFupload.tools.transField(element_id [String], config [optional Object]), multiple [bool optional])

xajax.ext.SWFupload.tools.transForm

This function parses the given form and replaces all file input fields inside the form.

Code: php

xajax.ext.SWFupload.tools.transForm('upload_form',{
 file_types : "*.jpg;*.gif", 
 file_types_description: "Web Image Files",
 file_size_limit : "3 MB"
 },
 true
 );

xajax.ext.SWFupload.tools.transField

This function replaces the given input field.

Code: php

xajax.ext.SWFupload.tools.transField('upload_field_id',{
 file_types : "*.jpg;*.gif", 
 file_types_description: "Web Image Files",
 file_size_limit : "3 MB"
 },
 false
 );

Both functions support passing an optional config object and the 'multiple' option. Setting the multiple option to true enables selecting multiple files at once The full reference for all configuration parameters can be found here: SWFUpload docs

xajax.ext.SWFupload.tools.destroyField

This function destroys the given input field and its associated objects.

Code: php

xajax.ext.SWFupload.tools.destroyField(field_id);


xajax.ext.SWFupload.tools.destroyForm

This function destroys the all fields and its associated objects of the given form.

Code: php

xajax.ext.SWFupload.tools.destroyForm(form_id);


response functions

All JavaScript functions are also available via xajax response commands.
  • $objResponse->clsSwfUpload->transForm($form_id,$config,$multiple)
  • $objResponse->clsSwfUpload->transField($form_id,$config,$multiple)
  • $objResponse->clsSwfUpload->destroyField($field_id)
  • $objResponse->clsSwfUpload->destroyForm($form_id)
  $objResponse->clsSwfUpload->transForm('upload_form'

Code: php

,array(
 "file_types" => "*.jpg;*.gif;*.png;"
 ,"file_types_description" => "Image Files or mp3"
 ,"file_size_limit" => "5 MB"
 ,"upload_complete_handler" => "function () {
 }"
 ,"post_params" => array(
 "PHPSESSID" => session_id()
 )
 )
 , true
 );	
 



« back
 


XAJAX on SourceForge.net
Support this project Valid XHTML 1.0 Transitional