Plugins Directory
You are not logged in. Log In
xajax.ext.SWFupload 0.2.1
Compatible with xajax Version 0.5 or newer
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
- fixed bug were response wasn't processed in IE
- 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
- 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
include the plugin right after the xajax object instantiation and before configuring xajax.
$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':
$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:
<input type="submit" value="upload" onclick"xajax_my_upload_function(xajax.getFormValues('my_form'),'foo','bar');" >
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.
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.
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.
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.
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'
,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
);
Download Sites for This Plugin
- Demo
http://www.xajaxproject.org/developer/q_no/swfupload/swfupload.php
- Download 0.2.1 (881kb zip)
http://www.xajaxproject.org/developer/q_no/swfupload/xajax.ext.SWFupload_0.2.1.zip
Submitted by: Steffen Konerow on 2008-04-06 22:26:07
E-mail: Steffen@nrg-media.de
Web site: http://xajaxproject.org
Filed under: Files > Response Commands, Javascript
You must be logged in...
...to rate or post a comment for this plugin. Log Into the Directory (registration handled via our xajax forums)
Go back to the Plugins Directory