Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Issue #25: Filter on the current site.

Making sure that the image plugin use the site filter so that only
images that are added to the current site can be used.
  • Loading branch information...
commit 8e8ec1523f039231d5ceab9289dd7159610602d8 1 parent 5c55534
@erlenddalen authored
Showing with 9,141 additions and 4 deletions.
  1. +5 −1 media_tree/admin/filenode_admin.py
  2. +9 −0 media_tree/contrib/cms_plugins/cms_app.py
  3. +7 −0 media_tree/contrib/cms_plugins/media_tree_image/cms_plugins.py
  4. +8 −0 media_tree/contrib/cms_plugins/media_tree_image/models.py
  5. +2 −0  media_tree/contrib/views/detail/__init__.py
  6. +1 −1  media_tree/fields.py
  7. +9 −0 media_tree/manage.py
  8. +7 −0 media_tree/middleware.py
  9. +2 −2 media_tree/models.py
  10. +315 −0 media_tree/static/media_tree/lib/swfupload/core changelog.txt
  11. +1,332 −0 media_tree/static/media_tree/lib/swfupload/documentation/index.html
  12. +4 −0 media_tree/static/media_tree/lib/swfupload/plugins/SWFObject License.txt
  13. +53 −0 media_tree/static/media_tree/lib/swfupload/plugins/swfupload.cookies.js
  14. +96 −0 media_tree/static/media_tree/lib/swfupload/plugins/swfupload.proxy.js
  15. +98 −0 media_tree/static/media_tree/lib/swfupload/plugins/swfupload.queue.js
  16. +346 −0 media_tree/static/media_tree/lib/swfupload/plugins/swfupload.speed.js
  17. +12 −0 media_tree/static/media_tree/lib/swfupload/swfupload license.txt
  18. +761 −0 media_tree/static/media_tree/lib/swfupload/swfupload_fp10/AsyncJPEGEncoder.as
  19. +28 −0 media_tree/static/media_tree/lib/swfupload/swfupload_fp10/EncodeCompleteEvent.as
  20. +144 −0 media_tree/static/media_tree/lib/swfupload/swfupload_fp10/ExternalCall.as
  21. +126 −0 media_tree/static/media_tree/lib/swfupload/swfupload_fp10/FileItem.as
  22. +203 −0 media_tree/static/media_tree/lib/swfupload/swfupload_fp10/ImageResizer.as
  23. +20 −0 media_tree/static/media_tree/lib/swfupload/swfupload_fp10/ImageResizerEvent.as
  24. +352 −0 media_tree/static/media_tree/lib/swfupload/swfupload_fp10/MultipartURLLoader.as
  25. +295 −0 media_tree/static/media_tree/lib/swfupload/swfupload_fp10/PNGEncoder.as
  26. +81 −0 media_tree/static/media_tree/lib/swfupload/swfupload_fp10/SWFUpload FP10.as3proj
  27. +1,679 −0 media_tree/static/media_tree/lib/swfupload/swfupload_fp10/SWFUpload.as
  28. +4 −0 media_tree/static/media_tree/lib/swfupload/swfupload_fp10/deploy.bat
  29. BIN  media_tree/static/media_tree/lib/swfupload/swfupload_fp10/jpegencoder.swc
  30. +1,132 −0 media_tree/static/media_tree/lib/swfupload/swfupload_fp10/swfupload.js
  31. BIN  media_tree/static/media_tree/lib/swfupload/swfupload_fp10/swfupload.swf
  32. +140 −0 media_tree/static/media_tree/lib/swfupload/swfupload_fp9/ExternalCall.as
  33. +123 −0 media_tree/static/media_tree/lib/swfupload/swfupload_fp9/FileItem.as
  34. +81 −0 media_tree/static/media_tree/lib/swfupload/swfupload_fp9/SWFUpload FP9.as3proj
  35. +1,572 −0 media_tree/static/media_tree/lib/swfupload/swfupload_fp9/SWFUpload.as
  36. +4 −0 media_tree/static/media_tree/lib/swfupload/swfupload_fp9/deploy.bat
  37. BIN  media_tree/static/media_tree/lib/swfupload/swfupload_fp9/swfupload_fp9.swf
  38. +41 −0 media_tree/templates/admin/media_tree/filenode/change_list_results_thumbnails.html
  39. +13 −0 media_tree/templates/media_tree/filenode/image.html
  40. +19 −0 media_tree/urls.py
  41. +17 −0 media_tree/views.py
View
6 media_tree/admin/filenode_admin.py
@@ -11,7 +11,7 @@
# TODO: Ordering of tree by column (within parent) should be possible
# TODO: Refactor SWFUpload stuff as extension. This would require signals calls
# to be called in the FileNodeAdmin view methods.
-
+from django.contrib.sites.models import Site
from media_tree.fields import FileNodeChoiceField
from media_tree.models import FileNode
@@ -132,6 +132,10 @@ def __init__(self, *args, **kwargs):
# http://stackoverflow.com/questions/1618728/disable-link-to-edit-object-in-djangos-admin-display-list-only
self.list_display_links = (None, )
+ def queryset(self, request):
+ qs = super(FileNodeAdmin, self).queryset(request)
+ return qs.filter(site=Site.objects.get_current())
+
def formfield_for_dbfield(self, db_field, **kwargs):
if db_field.name == 'parent' and issubclass(db_field.rel.to, FileNode):
# overriding formfield_for_dbfield, thus bypassign both Django's and mptt's
View
9 media_tree/contrib/cms_plugins/cms_app.py
@@ -0,0 +1,9 @@
+from cms.app_base import CMSApp
+from cms.apphook_pool import apphook_pool
+from django.utils.translation import ugettext_lazy as _
+
+class MediaTreeApphook(CMSApp):
+ name = _("Media Tree")
+ urls = ["media_tree.urls"]
+
+apphook_pool.register(MediaTreeApphook)
View
7 media_tree/contrib/cms_plugins/media_tree_image/cms_plugins.py
@@ -1,3 +1,4 @@
+from django.contrib.sites.models import Site
from media_tree.contrib.cms_plugins.media_tree_image.models import MediaTreeImage
from media_tree.contrib.cms_plugins.forms import MediaTreePluginFormBase
from media_tree.contrib.views.detail.image import ImageNodeDetailMixin
@@ -9,9 +10,15 @@
from django.utils.translation import ugettext_lazy as _
# TODO: Solve image_detail with get_absolute_url()?
+from media_tree.models import FileNode
class MediaTreeImagePluginForm(MediaTreePluginFormBase):
+
+ def __init__(self, *args, **kwargs):
+ super(MediaTreeImagePluginForm, self).__init__(*args, **kwargs)
+ self.fields['node'].queryset = FileNode.objects.filter(site=Site.objects.get_current())
+
class Meta:
model = MediaTreeImage
View
8 media_tree/contrib/cms_plugins/media_tree_image/models.py
@@ -1,3 +1,4 @@
+from django.contrib.sites.models import Site
from media_tree import media_types
from media_tree.contrib.cms_plugins import settings as plugins_settings
from media_tree.fields import FileNodeForeignKey, DimensionField
@@ -6,6 +7,11 @@
from django.utils.translation import ugettext_lazy as _
+class MediaTreeImageSiteManager(models.Manager):
+ def get_query_set(self):
+ return super(MediaTreeImageSiteManager, self).get_query_set().filter(node__site=Site.objects.get_current())
+
+
class MediaTreeImage(CMSPlugin):
node = FileNodeForeignKey(allowed_media_types=(media_types.SUPPORTED_IMAGE,), verbose_name=_('file'))
link_type = models.CharField(_('link type'), max_length=1, blank=True, null=True, default=plugins_settings.MEDIA_TREE_CMS_PLUGIN_LINK_TYPE_DEFAULT, choices=plugins_settings.MEDIA_TREE_CMS_PLUGIN_LINK_TYPE_CHOICES, help_text=_('Makes the image a clickable link.'))
@@ -16,5 +22,7 @@ class MediaTreeImage(CMSPlugin):
height = DimensionField(_('max. height'), null=True, blank=True, help_text=_('You can leave this empty to use an automatically determined image height.'))
render_template = models.CharField(_("template"), max_length=100, choices=None, blank=True, null=True, help_text=_('Template used to render the image.'))
+ objects = MediaTreeImageSiteManager()
+
def __unicode__(self):
return self.node.__unicode__()
View
2  media_tree/contrib/views/detail/__init__.py
@@ -1,3 +1,4 @@
+from django.contrib.sites.models import Site
from media_tree.models import FileNode
from media_tree.contrib.views.mixin_base import PluginMixin
from django.views.generic.detail import DetailView
@@ -75,6 +76,7 @@ def get_object(self, queryset=None):
def get_queryset(self, *args, **kwargs):
queryset = super(FileNodeDetailView, self).get_queryset(*args, **kwargs)
+ queryset = queryset.filter(node__site=Site.objects.get_current())
kwargs = {}
if self.filter_node_types:
kwargs['node_type__in'] = self.filter_node_types
View
2  media_tree/fields.py
@@ -31,7 +31,7 @@ def __init__(self, allowed_node_types=None, allowed_media_types=None, allowed_ex
self.allowed_node_types = allowed_node_types
self.allowed_media_types = allowed_media_types
self.allowed_extensions = allowed_extensions
- kwargs['level_indicator'] = level_indicator;
+ kwargs['level_indicator'] = level_indicator
if not kwargs.has_key('widget'):
kwargs['widget'] = self.widget
View
9 media_tree/manage.py
@@ -0,0 +1,9 @@
+#!/usr/bin/env python
+import os, sys
+
+if __name__ == "__main__":
+ os.environ.setdefault("DJANGO_SETTINGS_MODULE", "datakortet.settings")
+
+ from django.core.management import execute_from_command_line
+
+ execute_from_command_line(sys.argv)
View
7 media_tree/middleware.py
@@ -0,0 +1,7 @@
+from django.conf import settings
+
+class SessionPostMiddleware(object):
+
+ def process_request(self, request):
+ if not request.COOKIES.has_key(settings.SESSION_COOKIE_NAME) and request.POST.has_key(settings.SESSION_COOKIE_NAME):
+ request.COOKIES[settings.SESSION_COOKIE_NAME] = request.POST[settings.SESSION_COOKIE_NAME]
View
4 media_tree/models.py
@@ -87,7 +87,7 @@ def filter(self, *args, **kwargs):
"""
if 'path' in kwargs:
kwargs = self.get_filter_args_with_path(False, **kwargs)
- return super(FileNodeManager, self).filter(*args, **kwargs)
+ return super(FileNodeManager, self).filter(site=Site.objects.get_current()).filter(*args, **kwargs)
def exclude(self, *args, **kwargs):
"""
@@ -98,7 +98,7 @@ def exclude(self, *args, **kwargs):
"""
if 'path' in kwargs:
kwargs = self.get_filter_args_with_path(False, **kwargs)
- return super(FileNodeManager, self).exclude(*args, **kwargs)
+ return super(FileNodeManager, self).filter(site=Site.objects.get_current()).exclude(*args, **kwargs)
def get(self, *args, **kwargs):
"""
View
315 media_tree/static/media_tree/lib/swfupload/core changelog.txt
@@ -0,0 +1,315 @@
+ * SWFUpload Core, January 2009, www.swfupload.org, swfupload.googlecode.com
+
+ * --------- Version 2.5.0-----------
+ * + Added Client Side thumbnail generation and uploading and related settings
+ * -- Thanks to matzes for getting standard HTTP uploading to work
+ * + Added Alchemy based JPEG Encoder (which is much much faster)
+ * = Fixed double encoding of settings issue
+ * = Improved movieElement grabbing
+ * - Removed settings clone as it is unreliable
+ * = Fixed speed plugin so it checks for a file before extending it
+ * + Progress event manually fired for 100% if not fired by Flash
+ * + mouseClick, mouseOver, mouseOut event and handler settings added
+ * - Removed BUTTON_ACTION.JAVASCRIPT constant and button_action_handler. These are replaced by the mouseClick event
+ * + Added proxy plugin
+ * - Removed swfobject plugin
+ * + Integrated swfobject with core code
+ * + Added swfupload_preload_handler event/setting
+ * + Added swfupload_load_failed_handler event/setting
+ * + Added flash9_url to support SWF split to support Flash Player 9 and Flash Player 10
+ * = Fixed param encoding issue
+ * = Fixed button cursor when no button image was loaded
+
+
+ * --------- Version 2.2.1-----------
+ * + Added requeueUpload and updated documentation
+ * + Added button_action type of JAVASCRIPT and a buttonAction event to trigger a JavaScript function when the Flash Button is clicked
+ * = Updated destroy method to make sure the testExternalInterface timer is cleared
+ * = Also fixed destroy so the element is removed in non-IE browsers
+ * = Also fixed destroy method to call cleanUp method rather than duplicating the code
+ * = Fixed scope issue in cleanUp method.
+ * = Fixed bug in Queue Plugin that prevented the queueComplete event from firing
+ * + The place holder element is now replaced with the same type of flow element (div for block, span for inline)
+
+
+ * --------- Version 2.2.0.1-----------
+ * - Removed requeueUpload due to bugs/poor testing
+ * = Fixed namespace conflict that broke stopUpload
+
+ * --------- Version 2.2.0-----------
+ * + Added button_placeholder setting that accepts a DOM element.
+ * + Added ability to requeue any file (including some improvement to internal queue state tracking)
+ * + UploadErrors caused by a missing upload_url now causes the file to be requeued automatically
+ * + Added preserve_relative_urls setting
+ * + SWFUpload now converts relative URLs to absolute URLs to avoid issues with Flash Player interpreting it differently on some clients
+ * + Added assume_success_timeout setting which allows uploadSuccess to be called after a timeout if, for some reason Flash ignores the server's response
+ * An additional parameter has been added to the uploadSuccess event to indicate whether a response was received or success was assumed.
+
+ * --------- Version 2.2.0 Beta 2 ~ 5-----------
+ * = Fixed a Queue Limit bug
+ * + Improved internal event handling code so uploadSuccess fires even when not content is returned from the server (*woot*, except for Macs)
+ * = Fixed issues in Destroy
+ * = Fixed issues with Queue Plugin
+ * + Added periodic checks of the ExternalInterface
+ * + Improved IE memory leak prevention code
+ * + Added Speed Plugin
+ * = Updated Queue Plugin for better multi-plugin compatibility
+
+ * --------- Version 2.2.0 Beta 1-----------
+ * + Added Flash Player 10 Support
+ * = Added setting for defining a button image
+ * = Added setting for defining button text
+ * = Added setting for defining button width, height and padding
+ * = Added setting for defining what element the Flash Movie should replace
+ * = Added setting for defining flash wmode
+ * = Added setting for defining the mouse cursor
+ * + Added prevent_swf_caching setting as a work-around for issues in Avant Browser (and other IE based browser)
+ * + Added setting for accepting HTTP Status codes other than 200 as successful
+ * + Added parameter to cancelUpload that allows the uploadError event for cancelled uploads to be supressed
+ * + Added pro-active memory leak fix for IE and fixed problems with the destroy function (credits to steffen for patches and testing)
+ * + Replaced callFlash with CallFunction (using the internal function that Flash uses). Based on code from MooTools.
+ * = Fixed bug in the Queue plugin that breaks startUpload when passing a file id.
+ * + Updated Queue plugin to stop the queue if false is returned from the uploadStart handler.
+ * = Fixed small issues in SWFObject plugin
+ * = Fixed issue with ExternalInterface string escaping
+ * - Dropped Graceful Degradation Plugin
+ * - Dropped v1.0.2 Plugin
+ * - Dropped Flash Player 8 support
+
+ * --------- Version 2.1.0 -----------
+ * = Fixed GET values so they are escaped properly
+ * + Added destroy function
+ * = Added exception handling around browse() calls
+ * = Minor code cleanup
+ * + Split Core and Demos
+
+ * --------- Version 2.1.0 Beta 2-----------
+ * = Fixed bug in XHTML fix where it wasn't split correctly by Flash
+ * = Fixed file params "undefined" in debug output
+ * + Added requeue_on_error settings so HTTP/IO/Security errors requeue the file instead of discarding it.
+ This will affect the queue plugin (if an error is occurring the file will be reuploaded and reuploaded).
+ * = Fixed HTTP/IO error behavior. We'll see how this goes Flash 9 is supposed to call HTTPError followed by an IO error but I suspect they come out of orde sometimes.
+ * = Fixed invalid characters in file param names. Worked around flash bug by escaping the names. Should be transparent to devs.
+ * = Fixed missing upload URL logic so it fires consistently
+ * = Fixed file params not being sent when useQueryString is true
+ * + Added SWFObject plugin and demo.
+ * + Added CookieBug demo to demonstrate what they bug really is all about.
+ * + Added VB.Net version of the Application Demo
+
+
+ * --------- Version 2.1.0 Beta 1-----------
+ * + Added allowScriptAccess="always" to the embed/object elements so the SWF can be served from different domains.
+ * = Fixed a type-o in the debug output that prevented the instance id (movieName) from displaying. - Thx Joel
+ * + Rewrote SWFUpload.js for better code reuse based on sample code from batiste.bieler (thanks!!!)
+ * + Added queueComplete event to the Queue Plugin
+ * + Added Simple Upload demo
+ * = JSLinted all the JavaScript code
+ * + Added use_query_string setting (and setUseQueryString function) that forces post_param and file_param values to be sent on the query_string instead of the post (for Flash 9 version)
+ * = Fixed file.type and date properties so a default value is provided (rather than null) when no value is provided by flash.
+ * = Fixed misc bugs in the demos
+ * = Fixed ExternalInterface calls being made available for Flash 9 versions <9.0.28 which aren't supported
+ * + Fixed use of & producing invalid XHTML in the <object> and <embed> tags.
+ * - Removed the use of the embed tag (using the <object> sample from the Flash Satay method)
+ * = Updated plugins to work with code rewrite changes.
+ * = Extracted FileProgress object in to its own file.
+ * + Added addPostParam and removePostParam functions
+
+ * --------- Version 2.0.2 -----------
+ * = Fixed a bug where post params could not be added to the current file (because it is removed from the queue when it becomes current)
+ * = Fixed a conversion error when converting kilobytes to bytes in the file size check
+ * = Fixed a problem in the documentation that said the file_size_limit was bytes when it is actually kilobytes
+ * + Added formatting to the documentation, a table of contents, and details for each setting .
+ * + Added units for file_size_limit setting. The setting understands B, KB, MB, GB. Default is KB.
+ * + Added a check for the ExternalInterface functions in flashReady so SWFUpload will not fire the loaded event if those are not available.
+
+ * --------- Version 2.0.1 -----------
+ * = Fixed a bug where zero-byte files would stop file the queuing process.
+ * = Finished updating Features Demo
+ * + Added GetFileByIndex(i) that gets a JavaScript File Object. The index never changes. Finished files continue to be available.
+ * The JavaScript GetFile function will accept a file_id or an index.
+ * + Added CheckFileSize constants to replace the magic numbers
+ * + Added some code in an attempt to fix "Script is running slowly" error messages
+ * = Better cleanup of FileReference objects
+
+ * --------- Version 2.0 -----------
+ * + Re-created SWFUpload in Actionscript v2 for Flash 8 compatibility. Flash 8 loses POST and Server Data features. The two versions are otherwise fully compatible.
+ * Flash 8 uses URL to pass post_params/file_params.
+ * = Changed uploadStart event so it's part of the setTimeout/eventQueue workaround. This allows Flash functions to be called from uploadStart.
+ * = Renamed uploadComplete to uploadSuccess and fileComplete to uploadComplete. All started uploads call uploadComplete (even if cancelled or stopped).
+ * = Changed startUpload validation failure behavior. Rather than cancelling the upload the file is now requeued. Devs can cancel
+ * or do whatever the need to in uploadError to handle the problem.
+ * = Fixed fileQueueLimit/fileUploadLimit logic so it works correctly.
+ * = Moved the upload request building to a later point so that the post params and file params can be updated in uploadStart.
+ * - Removed the last of the UI stuff (ui_container, degraded_container).
+ * + Started development on Plug-ins. Graceful Degradation, v1.0.2, Cookies, Queue Handling
+ * = Fixed missing file_status field in FileItem.
+ * + Added modificationDate to FileItem (file object)
+ * + Added setStats function that lets you change the file upload count, etc. This will give more power over the queue limits. Not well tested.
+ * = Renamed compeleted_uploads to successful_uploads in getStats object
+ * + Added in_progress to getStats object
+
+ * --------- Revision 7.0 beta 3 -----------
+ * + Added an "event queue". Events are added to an array and executeEvent is called on a setTimeout. This prevents out of order issues that occur
+ * in the Safari browser.
+ * + Added a check for the UPLOAD_COMPLETE_DATA event constant which only became available in Flash Player 9.0.28. This
+ * fixes the Flash Version detection (Flash Object Detection) which was accepting Flash Player 9 versions before 9.0.28.
+ * - Removed old code block that was missed when moving from a Flash Timer to the JavaScript timeout (caused certain cancel events to be called twice)
+ * = Change ShowUI to the swfUploadLoaded event which will hopefully make it more clear that this is an overrideable event
+ * = Changed flashReady to behave like the other events (uses setTimeout and the Event Queue).
+
+ * --------- Revision 7.0 beta 2 -----------
+ * = Changed ERROR_CODE_FILE_NOT_FOUND to ERROR_CODE_FILE_ID_NOT_FOUND
+ * + Grouped the error code constants in objects for queue errors and upload errors.
+ * + Added an UPLOAD_STOPPED error code.
+ * = Changed Event calling method (using Timer) in Flash. Timer is no longer called
+ * instead setTimeout is called in JavaScript. This includes a change to the
+ * JavaSCript design so the Event methods are not directly overridden but stored
+ * internally and called if defined (with a setTimeout). This is an effort
+ * be more compatible with the current Flash Player on Linux
+ * = Changed the parameter order for the fileQueueError and uploadError events so the fileObj is first, like other events.
+ * + Added an empty JavaScript object (customSettings) where users can store settings associated with the instance.
+ * + Worked around an escaping bug in the ExternalInterface library by escaping all backslashes in out-going strings.
+ * = Updated all the demos.
+
+ * --------- Revision 7.0 beta 1 -----------
+ * = Redesigned the Event Chain
+ * - Removed much of the queue concepts
+ * - Removed the fileValidation events. This can be done in the new uploadStart event
+ * - Removed beginUploadOnQueue feature. This can be done in the new dialogComplete event.
+ * - Removed use_server_data. This is now always on.
+ * + Added functions for retrieving queue stats (number of files uploaded, queued, errors, etc)
+ * + Added a file status property to the FileObject. This indicates, uploaded, error, waiting.
+ * + Added a single file browser (user cannot select multiple files)
+ * + Fixed bug (hopefully) caused if Flash call to JavaScript and in the callback JavaSCript calls to Flash
+ * This only place this does not apply is to uploadStart. If you call in to Flash from uploadStart use a setTimeout to do it.
+
+ * --------- Revision 6.2 -----------
+ * + Added API calls for changing all the changeable settings dynamically
+ * = Fixed a bug in FileComplete event handler (in the SWF) that caused an error in Debug Players
+ * and prevent the event from being called
+ * + Added a setting (use_server_data_event) to indicate whether FileComplete or ServerData should be called.
+ * The SWFUpload architecture requires that only one file upload success event can be called.
+ * = Updated all the Demos, especially the Features Demo and the Forms Demo
+
+
+ * --------- Revision 6 -----------
+ * - Removed the call to setUploadSettings in flashReady. This was a left over call that is unnecessary.
+ * + Finished the parsing of post params during the init stage. This ommision was hidden by the call to setUploadSettings.
+ * - Removed the flash_target_id setting. The Flash file should only ever be added to the body tag.
+ * + Fixed (hopefully for good) another SWF race condition. IE executes the SWF very very early. The this.movieElement value should never be referenced.
+ * The movie Element should always be retrieved using this.getMovieElement().
+
+ * --------- Revision 6 -----------
+ * + Ported to ActionScript 3. Revision 6 requires Flash Player 9.
+ * = Fixed bug caused when cancelling single files. Would break any function that searched for a file_id.
+ * - Removed the automatic cookie sending setting. Devs should just pass the value they want to send in the post_params
+ * - Removed the query params settings (global and file specific). All params should be sent in the post_params
+ * + Added post_params which adds post values to the file upload post.
+ * + Added validate_files setting flag which causes the fileValidation event to be called before each file is uploaded.
+ * + Added fileValidation event. Return false if validation fails and true if validation is successful.
+ * + Added server_data parameter to the fileComplete event which returns any text that the upload script returns.
+ * = Updated all demos to work with Revision 6
+ * + Added in-code file extension validation. Before a file is queued the extension is checked against the valid extensions.
+ * Files the have invalid extensions cause the error event to be raised.
+ * + Added 'file_post_name' setting that allows the post variable name containing the file data to be named something other than 'Filedata'
+ * = Fixed a race condition in loadFlash where a cached flash movie would execute before this.movieElement could be assigned and loading would fail.
+
+ * --------- Revision 5.2 -----------
+ * = A little more code cleaning and variable renaming
+ * + Changed from an array queue to a FIFO queue. This eliminates the "current_index" and
+ * should reduce some memory usage.
+ * + Added out of order file uploading. Call StartUpload(/file_id/).
+ * + Added custom query_string parameters in addition to the cookies
+ * + Added the ability to modify the URL, cookies, params and send to flash
+ * + Added per file query_string params
+ * + Added files queued limit. Sometimes you may want the user to only queue one file at a time (or something)
+ * + Fixed limits so a zero(0) value means unlimited.
+
+ * --------- Revision 5 -------------
+ * = More code cleaning. Ported SWF to FlashDevelop. (Since my Flash Studio trial expired)
+ * The port to FlashDevelop is a big deal. It significantly changes the code structure
+ * and could introduce bugs. Also there have been reported issues with the FlashDevelop
+ * version from swfupload.mammon.se: Doesn't start when reloading in IE. Doesn't start
+ * in Firefox if the SWF file is visible because of a page scroll.
+ * + I fixed the Firefox issue by removing the wmode attribute from the embed object.
+ * + I cannot reproduce the IE issue on my local machine (although I can reproduce it at swfupload.mammon.se)
+ * + Event Handlers are now attached to the SWFUpload javascript object. The SWF file
+ * now calls the handlers in the context of the SWFUpload object which means the "this"
+ * object inside the handler refers to the proper SWFUpload instance.
+ * + Tested and Fixed upload target cookie attachment
+ * = Cleaned up / renamed everything for clarity and consistancy
+ * + File queuing is now subject to the upload limit. If the user attempts to queue more files
+ * than allowed an error is returned and the files are not queued.
+ * + Fixed misc bugs and text encodings.
+ * + Added more debug info for the SWF file.
+ * + SWF file now obeys the debug setting.
+ * + Added SetUploadTargetURL function that allows you to "dynamically" change the upload target
+ * + Added error code for zero byte file uploads which always return an IO error. The files are now rejected
+ * instead of being uploaded.
+
+ * --------- Revision 4 -------------
+ * = Cleaned up code. Added comments. Reorganized. Added more try..catches. Removed old unused methods.
+ * - Removed the 'create_ui' setting. The UI is now completely up to the developer.
+ * + Added upload_backend_cookies setting. Can set a string, or array of cookie names. These values will be
+ * passed as part of the upload_backend url
+ *
+ * = Changed QueueComplete event to only fire if at least one file has been successfully uploaded.
+ * + Added "Stop Upload" feature.
+ * = Revised the FLA file to clean things up, better handle errors, etc.
+ * = Fixed a bug where cancelling the first upload would cause the remaining uploads to fire before calling
+ * "startUpload". This change is in the FLA.
+ *
+ * + Fixed a bug in the upload.swf that prevented further file processing after an error is returned.
+ * + Added uploadLimit variable. Only complete uploads are counted. Once the limit is reached the flash
+ * movie will not upload any more files. (The ability to select or queue many files is not affected
+ * by the upload limit)
+ * + Added cancelQueue and cancelUpload methods.
+ * + Added ID property to the FileObj in the upload.swf
+ * + Added Upload and Queue settings
+ * + Added methods for generating the flash HTML and inserting it into the DOM.
+ * - Removed SWFObject
+ * + Updated the upload.swf and added the "flashReady" event. This will only call back
+ * for Flash 8 and above. With this we don't need a flash version detect script.
+ * The script initializes the Flash then waits for the Callback to init the UI.
+ * + Added seperate ui_target, degraded_target, create_ui settings. This allows fine control
+ * over what parts of the GUI the script displays and hides
+ *
+ * + Changed from a Static Class to an Instance (changed code/class structure)
+ * + Added "flash_version" setting. When set to zero the version check is skipped
+ * + Added Debug Console. The Instance class can't do document.write.
+ * = De-obfuscated SWFObject a bit
+ * - Removed standalone mode.
+ * + Added "ui_target" setting. When non-blank the link is added.
+ * + Added "flash_target" setting. When blank the flash is appended to the <body> tag
+ * = This fixes ASP.Net not allowing the flash to be added to the Form
+ * + Added error checking to the callSWF method
+ *
+
+
+ * -------- -------- -------- -------- -------- -------- -------- --------
+ * SWFUpload 0.7: Flash upload dialog - http://profandesign.se/swfupload/
+ * SWFUpload is (c) 2006 Lars Huring, Olov Nilz�n and Mammon Media and is released under the MIT License:
+ * http://www.opensource.org/licenses/mit-license.php
+ * -------- -------- -------- -------- -------- -------- -------- --------
+
+ * SWFUpload 0.7: Flash upload dialog - http://profandesign.se/swfupload/
+ *
+ * VERSION HISTORY
+ * 0.5 - First release
+ *
+ * 0.6 - 2006-11-24
+ * - Got rid of flash overlay
+ * - SWF size reduced to 840b
+ * - CSS-only styling of button
+ * - Add upload to links etc.
+ *
+ * 0.7 - 2006-11-27
+ * - Added filesize param and check in SWF
+ *
+ * 0.7.1 - 2006-12-01
+ * - Added link_mode param for standalone links
+ * if set to "standalone", createElement("a") won't run.
+ * - Added link_text param if css isn't needed.
+ * - Renamed cssClass to css_class for consistency
+ *
+ */
View
1,332 media_tree/static/media_tree/lib/swfupload/documentation/index.html
@@ -0,0 +1,1332 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" >
+<head>
+ <title>SWFUpload v2 Documentation</title>
+</head>
+
+<style type="text/css">
+ h1 /* Title */ {
+ }
+ h2 /* Chapter Header */ {
+ background-color: #DCE7F2;
+ border: solid 1px #CCD7E0;
+ padding: 10px;
+
+ margin-top: 50px;
+ margin-left: 5px;
+ }
+ h3 /* Section Header */ {
+ background-color: #EDFFEB;
+ padding: 10px;
+
+ margin-left: 15px;
+ }
+ h4 {
+ background-color: #FFFFD1;
+ padding: 7px;
+
+ margin-left: 20px;
+ }
+
+ h5 {
+ background-color: #F0F0F0;
+ padding: 4px;
+
+ font-weight: normal;
+
+ margin-left: 25px;
+ }
+
+ p {
+ margin-left: 35px;
+ }
+ span.function {
+ font-weight: bold;
+ }
+ span.parameter {
+ font-style: italic;
+ font-weight: normal;
+ }
+
+ hr {
+ margin-right: 25px;
+ }
+
+ ul, ol {
+ list-style-position: outside;
+ margin: 0;
+ padding: 0;
+ margin-left: 50px;
+ }
+ li {
+ padding-left: 15px;
+ }
+
+ code {
+ display: block;
+ border: solid 1px #EFEFEF;
+ background-color: #FAFAFA;
+ padding: 15px;
+ margin-left: 25px;
+
+ white-space: pre;
+
+ overflow-x: scroll;
+ overflow-y: visible;
+ }
+</style>
+
+<body>
+ <h1>SWFUpload v2.5.0 Documentation</h1>
+ <h2>Table of Contents</h2>
+ <ol>
+ <li><a href="#swfupload">SWFUpload</a></li>
+ <li><a href="#v2">SWFUpload Version 2</a></li>
+ <li><a href="#overview">Overview</a></li>
+ <li><a href="#gettingstarted">Getting Started</a></li>
+ <li><a href="#javascriptobject">SWFUpload JavaScript Object</a>
+ <ol>
+ <li><a href="#constructor">Constructor</a></li>
+ <li><a href="#globals">Globals and Constants</a>
+ <ol>
+ <li><a href="#instances">instances</a></li>
+ <li><a href="#movieCount">movieCount</a></li>
+ <li><a href="#queue_error">QUEUE_ERROR</a></li>
+ <li><a href="#upload_error">UPLOAD_ERROR</a></li>
+ <li><a href="#file_status">FILE_STATUS</a></li>
+ <li><a href="#upload_type">UPLOAD_TYPE</a></li>
+ <li><a href="#button_action">BUTTON_ACTION</a></li>
+ <li><a href="#button_cursor">CURSOR</a></li>
+ <li><a href="#button_window_mode">BUTTON_WINDOW_MODE</a></li>
+ <li><a href="#resize_encoding">RESIZE_ENCODING</a></li>
+ <li><a href="#onload">onload</a></li>
+ </ol>
+ </li>
+ <li><a href="#properties">Properties</a>
+ <ol>
+ <li><a href="#customSettings">customSettings</a></li>
+ <li><a href="#movieName">movieName</a></li>
+ </ol>
+ </li>
+ <li><a href="#methods">Methods</a>
+ <ol>
+ <li><a href="#addSetting">addSetting</a> (deprecated)</li>
+ <li><a href="#getSetting">getSetting</a> (deprecated)</li>
+ <li><a href="#retrieveSetting">retrieveSetting</a> (removed in v2.1.0)</li>
+ <li><a href="#destroy">destroy</a> (added in v2.1.0)</li>
+ <li><a href="#displayDebugInfo">displayDebugInfo</a></li>
+ <li><a href="#selectFile">selectFile</a></li>
+ <li><a href="#selectFiles">selectFiles</a></li>
+ <li><a href="#startUpload">startUpload</a></li>
+ <li><a href="#startResizedUpload">startResizedUpload (added in v2.5.0)</a></li>
+ <li><a href="#cancelUpload">cancelUpload</a></li>
+ <li><a href="#stopUpload">stopUpload</a></li>
+ <li><a href="#requeueUpload">requeueUpload</a></li>
+ <li><a href="#getStats">getStats</a></li>
+ <li><a href="#setStats">setStats</a></li>
+ <li><a href="#getFile">getFile</a></li>
+ <li><a href="#getQueueFile">getQueueFile (added in v2.5.0)</a></li>
+ <li><a href="#addPostParam">addPostParam</a></li>
+ <li><a href="#removePostParam">removePostParam</a></li>
+ <li><a href="#addFileParam">addFileParam</a></li>
+ <li><a href="#removeFileParam">removeFileParam</a></li>
+ <li><a href="#setUploadURL">setUploadURL</a></li>
+ <li><a href="#setPostParams">setPostParams</a></li>
+ <li><a href="#setFileTypes">setFileTypes</a></li>
+ <li><a href="#setFileSizeLimit">setFileSizeLimit</a></li>
+ <li><a href="#setFileUploadLimit">setFileUploadLimit</a></li>
+ <li><a href="#setFileQueueLimit">setFileQueueLimit</a></li>
+ <li><a href="#setFilePostName">setFilePostName</a></li>
+ <li><a href="#setUseQueryString">setUseQueryString</a></li>
+ <li><a href="#setDebugEnabled">setDebugEnabled</a></li>
+ <li><a href="#setButtonImageURL">setButtonImageURL (added in v2.2.0)</a></li>
+ <li><a href="#setButtonDimensions">setButtonDimensions (added in v2.2.0)</a></li>
+ <li><a href="#setButtonText">setButtonText (added in v2.2.0)</a></li>
+ <li><a href="#setButtonTextStyle">setButtonTextStyle (added in v2.2.0)</a></li>
+ <li><a href="#setButtonTextPadding">setButtonTextPadding (added in v2.2.0)</a></li>
+ <li><a href="#setButtonDisabled">setButtonDisabled (added in v2.2.0)</a></li>
+ <li><a href="#setButtonAction">setButtonAction (added in v2.2.0)</a></li>
+ <li><a href="#setButtonCursor">setButtonCursor (added in v2.2.0)</a></li>
+ </ol>
+ </li>
+ <li><a href="#events">Events</a>
+ <ol>
+ <li><a href="#flashReady">flashReady</a></li>
+ <li><a href="#swfUploadPreload">swfUploadPreload</a></li>
+ <li><a href="#swfUploadLoadFailed">swfUploadLoadFailed</a></li>
+ <li><a href="#swfUploadLoaded">swfUploadLoaded</a></li>
+ <li><a href="#buttonAction">buttonAction</a></li>
+ <li><a href="#fileDialogStart">fileDialogStart</a></li>
+ <li><a href="#fileQueued">fileQueued</a></li>
+ <li><a href="#fileQueueError">fileQueueError</a></li>
+ <li><a href="#fileDialogComplete">fileDialogComplete</a></li>
+ <li><a href="#uploadResizeStart">uploadResizeStart</a></li>
+ <li><a href="#uploadStart">uploadStart</a></li>
+ <li><a href="#uploadProgress">uploadProgress</a></li>
+ <li><a href="#uploadError">uploadError</a></li>
+ <li><a href="#uploadSuccess">uploadSuccess</a></li>
+ <li><a href="#uploadComplete">uploadComplete</a></li>
+ <li><a href="#debug">debug</a></li>
+ </ol>
+ </li>
+ <li><a href="#utility">SWFUpload Utility Objects</a>
+ <ol>
+ <li><a href="#settingsobject">Settings Object</a></li>
+ <li><a href="#settingsdescription">Settings Description</a></li>
+ <li><a href="#supportobject">Support Object</a></li>
+ <li><a href="#fileobject">File Object</a></li>
+ <li><a href="#statsobject">Stats Object</a></li>
+ </ol>
+ </li>
+ </ol>
+ </li>
+ <li><a href="#plugins">SWFUpload Plug-ins</a></li>
+ <li><a href="#knownissues">Known Issues</a></li>
+ </ol>
+
+
+ <h2><a name="swfupload"></a>SWFUpload</h2>
+ <p>
+ <a href="http://www.swfupload.org">SWFUpload</a> is a client-side file upload tool originally developed by <a href="http://www.vinterwebb.se/">Vinterwebb.se</a>. It uses a combination of Flash and JavaScript to
+ provide file upload functionality beyond what the basic browser provides with the &lt;input type="file" /&gt; tag.
+ </p>
+ <p>The main features that SWFUpload provides are:</p>
+ <p>
+ <ul>
+ <li>The ability to select multiple files in the file browser dialog.</li>
+ <li>AJAX-style uploading without a page refresh.</li>
+ <li>Upload progress events.</li>
+ <li>Client-side image resizing</li>
+ <li>Namespaced classes compatible with other JavaScript libraries (i.e., jQuery, Prototype, etc.).</li>
+ <li>Flash 9 and Flash 10 support. (Flash 8 support dropped in version 2.2.0)</li>
+ </ul>
+ </p>
+ <p>
+ SWFUpload is different from other Flash based upload tools because of the philosophy
+ behind its design. SWFUpload gives developers control by leaving the UI in the browser (as much as possible).
+ Developers can use XHTML, CSS, and JavaScript to tailor the upload UI to the needs and
+ style of their site. Upload status updates are made through a set of simple JavaScript events.
+ The developer uses these events to update the webpage as the file upload progresses.
+ </p>
+ <p>
+ Unfortunately Flash Player 10 has forced us have one button in a flash movie in order to trigger the file browser dialog window. SWFUpload
+ still empowers the devloper by provding the ability the button and overlay text from JavaScript.
+ </p>
+
+ <h2><a name="v2"></a>SWFUpload v2</h2>
+ <p>
+ SWFUpload v2 includes new advanced features, improved stability, Flash Player
+ bug work-arounds and a helpful set of Plug-ins. New features include:
+ </p>
+ <p>
+ <ul>
+ <li>Flash Player 10 security compatibility.</li>
+ <li>The ability to send additional POST values with the uploads.</li>
+ <li>Sending per file POST values.</li>
+ <li>Complete set of events.</li>
+ <li>All settings dynamically updateable.</li>
+ <li>Retrieve result data from the server.</li>
+ <li>Stop an upload without cancelling.</li>
+ <li>Upload files in any order.</li>
+ <li>Multi- &amp; Single-file selection dialogs.</li>
+ <li>Queue size, files uploaded and file size limits.</li>
+ <li>Properly handling of zero-byte files.</li>
+ <li>Pre-upload validation event.</li>
+ <li>Work-arounds for bugs in Flash and Browser.</li>
+ </ul>
+ </p>
+
+ <h2><a name="overview"></a>Overview</h2>
+ <h3>HTML Upload</h3>
+ <p>
+ The standard HTML upload input box provides a box and a button to the user for selecting a file.
+ The file is submitted with the form. The entire file must be uploaded before the next
+ page is displayed. No pre-upload validation can be made on the file (e.g., file size limits or valid extensions).
+ Very little feedback is given to the user while the file uploads.
+ </p>
+ <p>
+ The usage pattern for standard HTML uploads is simple, straight forward, and supported by nearly all browser.
+ </p>
+ <h3>SWFUpload</h3>
+ <p>
+ SWFUpload uses a Flash movie to handle file selection and upload. A customizable button is displayed by the
+ Flash movie that activates Flashes advanced file selection dialog window.
+ The file selection dialog is configured to allow the user select to a single file or multiple files.
+ The file types can be restricted so users only select the appropriate files (e.g., *.jpg;*.gif).
+ </p>
+ <p>
+ Once selected each file is validated and queued. As the file is uploaded by Flash
+ several JavaScript events are fired which the developer handles in order to update the page's UI allowing you to provide
+ upload status and error messages in real-time.
+ </p>
+ <p>
+ The uploaded file is submitted separately from the rest of the page and form. Each file is uploaded
+ individually keeping the server-side upload handling script simple. Since Flash is providing the upload
+ service the page does not have to be submitted or reloaded. The usage pattern for SWFUpload is more
+ like that of an AJAX application than that of a standard HTML form. The page's form will be processed
+ separately from the file upload.
+ </p>
+ <h2><a name="gettingstarted"></a>Getting Started</h2>
+ <p>SWFUpload is not a drag &amp; drop upload control. It requires knowledge of JavaScript and the DOM. Several demos are available that
+ show some of the things SWFUpload is capable of and how to accomplish common tasks.</p>
+
+ <p>SWFUpload consists of 4 pieces:</p>
+ <ol>
+ <li>Initialization and Settings (JavaScript)</li>
+ <li>JavaScript library: SWFUpload.js</li>
+ <li>Flash Control: swfupload.swf &amp; swfupload_fp9.swf</li>
+ <li>The Event Handlers (JavaScript)</li>
+ </ol>
+
+ <p>Most problems implementing SWFUpload are caused by incorrect settings, poorly built event handlers, Flash/Browser Bugs, or server configuration.</p>
+
+ <h3>Initialization and Settings</h3>
+ <p>SWFUpload must be initialized on the page. This is commonly done in the window.onload event. The SWFUpload constructor takes a settings object.
+ The settings object can be passed directly to the constructor as an object literal.</p>
+ <p>A reference to the initialized SWFUpload object should be kept as it is needed to start uploads and to control other aspects of SWFUpload.</p>
+
+ <p><strong>Example:</strong> Initializing SWFUpload with an object literal</p>
+
+ <code>var swfu;
+
+window.onload = function () {
+ swfu = new SWFUpload({
+ upload_url : "http://www.swfupload.org/upload.php",
+ flash_url : "http://www.swfupload.org/swfupload.swf",
+ flash9_url : "http://www.swfupload.org/swfupload_fp9.swf",
+ file_size_limit : "20 MB"
+ });
+};</code>
+
+ <p><strong>Example:</strong> Initializing SWFUpload with a settings object stored in a variable</p>
+
+ <code>var swfu;
+
+window.onload = function () {
+ var settings_object = {
+ upload_url : "http://www.swfupload.org/upload.php",
+ flash_url : "http://www.swfupload.org/swfupload.swf",
+ flash9_url : "http://www.swfupload.org/swfupload_fp9.swf",
+ file_size_limit : "20 MB"
+ };
+
+ swfu = new SWFUpload(settings_object);
+};</code>
+
+ <h3>JavaScript library</h3>
+ <p>The JavaScript library file (swfupload.js) must be included on the page where the user will upload files.</p>
+ <p>Once a SWFUpload object has been created access to several functions become available which allow the developer to control SWFUpload.</p>
+
+ <p><strong>Example:</strong> Adding SWFUpload.js to a page</p>
+
+ <code>
+&lt;script type="text/javascript" src="http://www.swfupload.org/swfupload.js"&gt;&lt;/script&gt;
+ </code>
+
+ <p><strong>Example:</strong> Initializing SWFUpload with the required settings.</p>
+ <code>var swfu = new SWFUpload({
+ upload_url : "http://www.swfupload.org/upload.php",
+ flash_url : "http://www.swfupload.org/swfupload.swf",
+ flash9_url : "http://www.swfupload.org/swfupload_fp9.swf",
+ button_placeholder_id : "spanSWFUploadButton"
+});
+</code>
+
+ <h3>Flash Control</h3>
+ <p>The SWFUpload JavaScript library dynamically loads the Flash Control (swfupload.swf/swfupload_fp9.swf).</p>
+
+ <p>The location of the Flash Control file must be provided in the SWFUpload settings object during setup.</p>
+
+ <p>The Flash Control is a small Flash Movie that handles file browsing, validation and upload. It appears on the page as
+ a button and communicates with JavaScript to notify the browser of upload status and other events.</p>
+
+ <p>New ActionScript syntax and classes require us to target Flash Player 10 and Flash Player 9 separately. SWFUpload will detect the installed version of flash and load the appropriate Flash Control.</p>
+
+ <p>Use the flash_url and flash9_url settings to defined custom locations and file names for the swfupload.swf and swfupload_fp9.swf files.</p>
+
+ <h3>The Event Handlers</h3>
+
+ <p>Developers must create a set of JavaScript functions that handle SWFUpload events. These functions are called as different important events occur.</p>
+
+ <p>By handling the SWFUpload events developers can provide feedback regarding the upload progress, error messages, and upload completion. Developers should not
+ overwrite functions stored in SWFUpload.prototype. Instead create your own set of functions and pass references to them in the settings object.</p>
+
+ <p><strong>Example:</strong> SWFUpload event handlers and initialization.</p>
+
+ <code>// The uploadStart event handler. This function variable is assigned to upload_start_handler in the settings object
+var myCustomUploadStartEventHandler = function (file) {
+ var continue_with_upload;
+
+ if (file.name === "the sky is blue") {
+ continue_with_upload = true;
+ } else {
+ continue_with_upload = false;
+ }
+
+ return continue_with_upload;
+};
+
+// The uploadSuccess event handler. This function variable is assigned to upload_success_handler in the settings object
+var myCustomUploadSuccessEventHandler = function (file, server_data, receivedResponse) {
+ alert("The file " + file.name + " has been delivered to the server. The server responded with " + server_data);
+};
+
+// Create the SWFUpload Object
+var swfu = new SWFUpload({
+ upload_url : "http://www.swfupload.org/upload.php",
+ flash_url : "http://www.swfupload.org/swfupload.swf",
+ flash9_url : "http://www.swfupload.org/swfupload_fp9.swf",
+ file_size_limit : "200 MB",
+
+ upload_start_handler : myCustomUploadStartEventHandler,
+ upload_success_handler : myCustomUploadSuccessEventHandler
+});</code>
+
+
+ <h2><a name="javascriptobject"></a>SWFUpload JavaScript Object</h2>
+
+ <h3><a name="constructor"></a>Constructor</h3>
+
+ <p><span class="function">SWFUpload(<span class="parameter">settings object</span>)</span></p>
+ <p><b>Returns:</b> A SWFUpload instance</p>
+ <code>var swfupload_instance = new SWFUpload(settings_object);</code>
+
+ <h3><a name="globals"></a>Globals and Constants</h3>
+ <p>
+ Several globals and constants are associated with the SWFUpload object. These are useful for
+ advanced SWFUpload applications and for handling errors. These are considered read-only.
+ </p>
+ <h4><a name="instances"></a>SWFUpload.instances</h4>
+ <p>SWFUpload.instances is an object containing a reference to each SWFUpload instance loaded on a page. The Flash Player
+ relies on this object in order to call the correct event handlers. SWFUpload.instances indexes by the movieName property.</p>
+
+ <h4><a name="movieCount"></a>SWFUpload.movieCount</h4>
+ <p>SWFUpload.movieCount is a global that tracks the number on SWFUpload instances that have been created and helps to ensure each movie is
+ given a unique movieName.</p>
+
+ <h4><a name="queue_error"></a>SWFUpload.QUEUE_ERROR</h4>
+ <p>SWFUpload.QUEUE_ERROR is a simple object that contains Queue Error code constants. It is generally used to determine which error code was sent
+ in the fileQueueError event.</p>
+
+ <ul style="padding-left: 15px;">
+ <li>QUEUE_LIMIT_EXCEEDED - indicates that the user has attempted to queue more files that is allowed by the settings. Once files have been updated and removed from the queue the user is again allowed to queue additional files.</li>
+ <li>FILE_EXCEEDS_SIZE_LIMIT - indicates the selected file is larger than is allwed by the file_size_limit.</li>
+ <li>ZERO_BYTE_FILE - indicates that the selected file is empty. The Flash Player cannot handle empty files and the file is rejected. Windows Shortcut files may also trigger this error.</li>
+ <li>INVALID_FILETYPE - The selected file's extension does not match a valid extension from the file_types setting. User's can circumvent the file_types restriction by manually entering a file name.</li>
+ </ul>
+
+ <h4><a name="upload_error"></a>SWFUpload.UPLOAD_ERROR</h4>
+ <p>SWFUpload.UPLOAD_ERROR is a simple object that contains Upload Error code constants. It is generally used to determine which error code was sent
+ in the uploadError event.</p>
+
+ <ul style="padding-left: 15px;">
+ <li>HTTP_ERROR - The file upload was attempted but the server did not return a 200 status code.</li>
+ <li>MISSING_UPLOAD_URL - The upload_url setting was not set.</li>
+ <li>IO_ERROR - Some kind of error occurred while reading or transmitting the file. This most commonly occurs when the server unexpectedly terminates the connection.</li>
+ <li>SECURITY_ERROR - The upload violates a security restriction. This error is rare.</li>
+ <li>UPLOAD_LIMIT_EXCEEDED - The user has attempted to upload more files than is allowed by the file_upload_limit setting.</li>
+ <li>UPLOAD_FAILED - The attempt to initiate the upload caused an error. This error is rare.</li>
+ <li>SPECIFIED_FILE_ID_NOT_FOUND - A file ID was passed to startUpload but that file ID could not be found.</li>
+ <li>FILE_VALIDATION_FAILED - False was returned from the uploadStart event</li>
+ <li>FILE_CANCELLED - cancelUpload was called</li>
+ <li>UPLOAD_STOPPED - stopUpload was called.</li>
+ <li>RESIZE_ERROR - An error occurred resizing an image</li>
+ </ul>
+
+ <h4><a name="file_status"></a>SWFUpload.FILE_STATUS</h4>
+ <p>SWFUpload.FILE_STATUS is a simple object that contains File Status code constants. It can be used to check the file status property on the File object.</p>
+
+ <ul style="padding-left: 15px;">
+ <li>QUEUED - indicates the this file is waiting in the queue.</li>
+ <li>IN_PROGRESS - indicates that this file is currently being uploaded.</li>
+ <li>ERROR - indicates that this file caused a queue or upload error.</li>
+ <li>COMPLETE - indicates that this file was successfully transmitted to the server.</li>
+ <li>CANCELLED - indicates that this file was cancelled by a call to cancelUpload.</li>
+ </ul>
+
+ <h4><a name="upload_type"></a>SWFUpload.UPLOAD_TYPE</h4>
+ <p>SWFUpload.UPLOAD_TYPE is a simple object that contains Upload Type constants. It can be used to check the upload type property on the File object.</p>
+
+ <ul style="padding-left: 15px;">
+ <li>NORMAL - a normal SWFUpload upload</li>
+ <li>RESIZED - a resized image upload. The data was not sent as an HTTP upload but as a simple post.</li>
+ </ul>
+
+ <h4><a name="button_action"></a>SWFUpload.BUTTON_ACTION</h4>
+ <p>SWFUpload.BUTTON_ACTION is a simple object that contains button action code constants. It is used with the button_action setting to set the behavior of the Flash based file dialog button.</p>
+
+ <ul style="padding-left: 15px;">
+ <li>SELECT_FILE - when the Flash button is clicked the file dialog will only allow a single file to be selected. The mouseClick event is not fired in this case.</li>
+ <li>SELECT_FILES - when the Flash button is clicked the file dialog allows multiple files to be selected. The mouseClick event is not fired in this case.</li>
+ <li>START_UPLOAD - when the Flash button is clicked the first queued file will be uploaded. The mouseClick event is not fired in this case.</li>
+ <li>NONE - when the Flash button is clicked the mouseClick event will be fired.</li>
+ <li>JAVASCRIPT - same as the NONE action. <strong>This value is deprecated.</strong></li>
+ </ul>
+
+ <h4><a name="button_cursor"></a>SWFUpload.CURSOR</h4>
+ <p>SWFUpload.CURSOR is a simple object that contains button cursor code constants. It is used with the button_cursor setting to set the mouse cursor when hovering over the Flash button.</p>
+
+ <ul style="padding-left: 15px;">
+ <li>ARROW - the cursor will display as an arrow pointer</li>
+ <li>HAND - the cursor will display has a finger/hand pointer</li>
+ </ul>
+
+ <h4><a name="button_window_mode"></a>SWFUpload.WINDOW_MODE</h4>
+ <p>SWFUpload.WINDOW_MODE is a simple object that contains button movie wmode parameter constants. It is used to tell the browser how to display the Flash Movie.</p>
+ <p>The some WINDOW_MODE/WMODE settings can cause problems in some browsers. See the <a href="#knownissues">Known Issues</a>.</p>
+
+ <ul style="padding-left: 15px;">
+ <li>WINDOW is the default mode. The movie is drawn over the top of all other elements on the page.</li>
+ <li>OPAQUE causes the movie to be rendered in the page allowing other elements to cover up the button.</li>
+ <li>TRANSPARENT the button background is rendered transparent allowing html elements under the button to show through.</li>
+ </ul>
+
+ <h4><a name="resize_encoding"></a>SWFUpload.RESIZE_ENCODING</h4>
+ <p>SWFUpload.RESIZE_ENCODING is a simple object that contains resize encoding type constants. It to indicate the format for encoding resized images.</p>
+
+ <ul style="padding-left: 15px;">
+ <li>JPEG - The JPEG encoding format</li>
+ <li>PNG - The PNG encoding format</li>
+ </ul>
+
+ <h4><a name="onload"></a>SWFUpload.onload</h4>
+ <p>onload is a function that will be executed by swfobject's addDOMLoadEvent. You can use onload to execute your script as soon as the page is ready. You should only use onload if you are not already using some other method (such as jQuery's Ready or Prototype's dom:loaded).</p>
+ <code>SWFUpload.onload = function () {
+ new SWFUpload(settingsObject);
+}</code>
+
+ <p>The above example will initialize SWFUpload using the browser's earliest load event. In most browsers this is the DOMReady event which often executes much sooner than the window.onload event.</p>
+
+ <h3><a name="properties"></a>Properties</h3>
+ <p>
+ The following list of properties is intended for your use as described below. Using other properties or
+ writing to read-only properties can cause SWFUpload to malfunction.
+ </p>
+ <h4><a name="customSettings"></a>customSettings (read/write)</h4>
+ <p>
+ The customSettings property is an empty JavaScript object that can be used to store data associated with
+ an instance of SWFUpload. The customSettings object contents can be initialized using the custom_settings setting.
+ </p>
+
+ <p><strong>Example:</strong></p>
+ <code>// Initialize SWFUpload with some custom settings
+var swfu = new SWFUpload({
+ custom_settings : {
+ custom_setting_1 : "custom_setting_value_1",
+ custom_setting_2 : "custom_setting_value_2",
+ custom_setting_n : "custom_setting_value_n",
+ }
+});
+
+swfu.customSettings.custom_setting_1 = "custom_setting_value_1"; // Change an existing custom setting
+swfu.customSettings.myNewCustomSetting = "new custom setting value"; // Add a new custom setting
+
+// Overwrite the customSettings with a completely new object
+swfu.customSettings = {
+ custom_setting_A : "custom_setting_value_A",
+ custom_setting_B : "custom_setting_value_B"
+};
+ </code>
+
+ <p>The values stored in the customSettings object can then be easily accessed in the event handlers: </p>
+
+ <code>
+function uploadSuccess(file, serverData, receivedResponse) {
+ if (this.customSettings.custom_setting_A === true) {
+ alert("Checked the custom setting!");
+ }
+}
+ </code>
+
+ <h4><a name="movieName"></a>movieName</h4>
+ <p>Contains the unique movie name of the SWFUpload instance. This value is passed to Flash and is used to facilitate Flash-to-JavaScript communication.
+ This value is used to index the instance in the SWFUpload.instances array. You should not change the movieName value.</p>
+
+ <h3><a name="methods"></a>Methods</h3>
+ <p>The following methods are used to operate SWFUpload. Some are bound to DOM element click event handlers and others are used inside
+ SWFUpload event handlers.</p>
+
+ <h4><a name="addSetting"></a>object addSetting(<span class="parameter">setting_name</span>, <span class="parameter">value</span>, <span class="parameter">default_value</span>)</h4>
+ <p><strong>Deprecated</strong> The addSetting function sets a setting value. If the value is undefined then the default_value is used. The function is used by SWFUpload
+ during initialization. Using addSetting to update a setting will not change the setting in the Flash Control.</p>
+ <p>addSetting returns the value that was stored in the setting.</p>
+
+ <h4><a name="getSetting"></a>object getSetting(<span class="parameter">setting_name</span>)</h4>
+ <p><strong>Deprecated</strong> The getSetting function retrieves the value of a setting. If the setting is not found an empty string is returned.</p>
+
+ <h4><a name="retrieveSetting"></a>object retrieveSetting(<span class="parameter">setting_value</span>, <span class="parameter">default_value</span>)</h4>
+ <p><strong>Removed in v2.1.0</strong> The retrieveSetting function is similar to the addSetting function except it does not modify the internal settings object. retrieveSetting
+ returns the setting_value unless it is undefined in which case it returns the default_value</p>
+ <p>This is a utility function.</p>
+
+ <h4><a name="destroy"></a>bool destroy()</h4>
+ <p><strong>Added in v2.1.0</strong></p>
+ <p>Removes the SWF DOM elements and then destroys SWFUpload internal references. Used for removing a SWFUpload instance from a page. It also attempts to prevent memory leaks in IE.</p>
+ <p>Returns true if the elements were removed successfully. Returns false if any error occurs leaving the SWFUpload instance in an inconsistent state.</p>
+
+ <h4><a name="displayDebugInfo"></a>void displayDebugInfo()</h4>
+ <p>The displayDebugInfo outputs SWFUpload settings using the debug event. This function is automatically called after initialization if the debug setting is 'true'</p>
+
+ <h4><a name="selectFile"></a>void selectFile()</h4>
+ <p><strong>Deprecated. Not compatible with Flash Player 10.</strong></p>
+ <p>selectFile causes the Flash Control to display a File Selection Dialog window. A single file may be selected from the Dialog window.</p>
+ <p>Calling selectFile begins the File Event Chain.</p>
+
+ <h4><a name="selectFiles"></a>void selectFiles()</h4>
+ <p><strong>Deprecated. Not compatible with Flash Player 10.</strong></p>
+ <p>selectFiles causes the Flash Control to display a File Selection Dialog window. A multiple files may be selected from the Dialog window.</p>
+ <p>Calling selectFiles begins the File Event Chain.</p>
+
+ <h4><a name="startUpload"></a>void startUpload(<span class="parameter">file_id</span>)</h4>
+ <p>startUpload causes the file specified by the file_id parameter to start the upload process. If the file_id parameter is omitted or undefined then the first file in the queue is uploaded.</p>
+
+ <p>Calling startUpload begins the Upload Event Chain.</p>
+
+ <h4><a name="startResizedUpload"></a>void startResizedUpload(<span class="parameter">file_id</span>, <span class="parameter">width</span>, <span class="parameter">height</span>, <span class="parameter">encoding</span>, <span class="parameter">quality</span>, <span class="parameter">allowEnlarging</span>)</h4>
+ <p>startResizedUpload causes the file specified by the file_id parameter to start the upload process. SWFUpload attempts to resize the file (assuming it is an image format supported by Flash). If the image cannot be resized an uploadError occurs.</p>
+
+ <p>The width and height parameters specify the maximum size the resized image can be in each dimension. The other dimension is scaled to maintain the image aspect ratio.</p>
+
+ <p>The encoding parameter should be a value from the SWFUpload.RESIZE_ENCODING constants.</p>
+
+ <p>The quality parameter is used only for JPEG encoding and can be value from 0 to 100. The value is clamped if it is out of range.</p>
+
+ <p>The allowEnlarging parameter defines whether SWFUpload is allowed to enlarge the original image when resizing. If set to false the image is still re-encoded but will not be enlarged.</p>
+
+ <p>Calling startResizedUpload begins the normal Upload Event Chain. However, the Flash Player does not provide periodic uploadProgress events. SWFUpload sends only simulated 0% and 100% uploadProgress events.</p>
+
+ <p>A resized image is uploaded as POST value (rather than a FILE) due to security &quot;features&quot; introduced in Flash Player 10. Resized images have to be handled differently than normal uploads:</p>
+
+ <code>$resizedImageData = $_POST["Filedata"]; // Data from $_POST rather than $_FILE
+$fileHandle = fopen("image.jpg", "w");
+fwrite($fileHandle, $resizedImageData);
+fclose($fileHandle);
+</code>
+
+ <h4><a name="cancelUpload"></a>void cancelUpload(<span class="parameter">file_id</span>, <span class="parameter">trigger_error_event</span>)</h4>
+
+ <p>cancelUpload cancels the file specified by the file_id parameter. The file is then removed from the queue.</p>
+ <p>If the file_id parameter is omitted or undefined then the first file in the queue is cancelled.</p>
+ <p>The trigger_error_event is optional. If set to false the uploadError event is suppressed.</p>
+
+ <h4><a name="stopUpload"></a>void stopUpload()</h4>
+
+ <p>stopUpload stops and re-queues the file currently being uploaded.</p>
+ <p>After the uploading file is stopped the uploadError event is fired. If no file is being uploaded then nothing happens and no event is fired.</p>
+
+ <h4><a name="requeueUpload"></a>bool requeueUpload(<span class="parameter">file_id or index</span>)</h4>
+
+ <p>requeueUpload requeues any previously queued file.</p>
+ <p>If the file cannot be found or is currently uploading false is returned.</p>
+ <p>
+ Requeued files are not checked against the file size, queue size, file upload limit or any other settings but are simply added to the queue if a valid
+ reference to a file exists.
+ </p>
+
+ <h4><a name="getStats"></a>object getStats()</h4>
+ <p>Retrieves the stats object.</p>
+
+ <h4><a name="setStats"></a>void setStats(<span class="parameter">stats_object</span>)</h4>
+ <p>The Stats Object may be modified. This is useful if you wish to change the number of successful uploads or upload errors after an upload
+ has completed.</p>
+
+ <h4><a name="getFile"></a>object getFile(<span class="parameter">file_id</span>|<span class="parameter">index</span>)</h4>
+ <p>getFile is used to retrieve a File Object from the queue. The file retrieved by passing in a file id (the id property from a file object) or a file index (the index property from a file object).</p>
+ <p>When getting a file by file_id only files in the queue are available. If the file is not found null is returned.</p>
+ <p>When getting a file by index all queued (or files that generated a queue error) are available. If the index is out of range then null is returned</p>
+
+ <h4><a name="getQueueFile"></a>object getQueueFile(<span class="parameter">file_id</span>|<span class="parameter">index</span>)</h4>
+ <p>getFile is used to retrieve a File Object from the upload queue. The file retrieved by passing in a file id (the id property from a file object) or a queue index (the position of the file in the queue). The index starts at zero.</p>
+ <p>When getting a file by file_id only files currently queued for upload are available. If the file is not found null is returned.</p>
+ <p>When getting a file by index only files currently queued for upload ar available. For example: getQueueFile(0) returns the file at front of the queue. This would be the next file uploaded when startUpload is called.</p>
+
+ <h4><a name="addPostParam"></a>void addPostParam(<span class="parameter">name</span>, <span class="parameter">value</span>)</h4>
+ <p>The addPostParam function adds a name/value pair that will be sent in the POST for all files uploaded.</p>
+ <p>The name/value pair will also appear in the post_params setting.</p>
+
+ <h4><a name="removePostParam"></a>void removePostParam(<span class="parameter">name</span>)</h4>
+ <p>The removePostParam function removes a name/value pair from the values sent with the POST for file uploads.</p>
+ <p>The name/value pair is also be removed from the post_params setting.</p>
+
+ <h4><a name="addFileParam"></a>bool addFileParam(<span class="parameter">file_id</span>, <span class="parameter">name</span>, <span class="parameter">value</span>)</h4>
+ <p>The addFileParam function adds a name/value pair that will be sent in the POST with the file specified by the file_id parameter.</p>
+ <p>The name/value pair will only be sent with the file it is added to. To send name/value pairs with all uploads use the post_param setting.</p>
+
+ <h4><a name="removeFileParam"></a>bool removeFileParam(<span class="parameter">file_id</span>, <span class="parameter">name</span>)</h4>
+ <p>The removeFileParam function removes a name/value pair from a file upload that was added using addFileParam.</p>
+ <p>If the name/value pair was not found then 'false' is returned.</p>
+
+ <h4><a name="setUploadURL"></a>void setUploadURL(<span class="parameter">url</span>)</h4>
+ <p>Dynamically modifies the upload_url setting.</p>
+
+ <h4><a name="setPostParams"></a>void setPostParams(<span class="parameter">param_object</span>)</h4>
+ <p>Dynamically modifies the post_params setting. Any previous values are over-written. The param_object should be a simple JavaScript object. All names and values must be strings.</p>
+
+ <h4><a name="setFileTypes"></a>void setFileTypes(<span class="parameter">types</span>, <span class="parameter">description</span>)</h4>
+ <p>Dynamically updates the file_types and file_types_description settings. Both parameters are required.</p>
+
+ <h4><a name="setFileSizeLimit"></a>void setFileSizeLimit(<span class="parameter">file_size_limit</span>)</h4>
+ <p>Dynamically modifies the file_size_limit setting. This applies to all future files that are queued. The file_size_limit parameter will accept a unit. Valid units are B, KB, MB, and GB. The default unit is KB.</p>
+ <p>Examples: 2147483648 B, 2097152, 2097152KB, 2048 MB, 2 GB</p>
+
+ <h4><a name="setFileUploadLimit"></a>void setFileUploadLimit(<span class="parameter">file_upload_limit</span>)</h4>
+ <p>Dynamically modifies the file_upload_limit setting. The special value zero (0) indicates "no limit".</p>
+
+ <h4><a name="setFileQueueLimit"></a>void setFileQueueLimit(<span class="parameter">file_queue_limit</span>)</h4>
+ <p>Dynamically modifies the file_queue_limit setting. The special value zero (0) indicates "no limit".</p>
+
+ <h4><a name="setFilePostName"></a>void setFilePostName(<span class="parameter">file_post_name</span>)</h4>
+ <p>Dynamically modifies the file_post_name setting. The Linux Flash Player ignores this setting.</p>
+
+ <h4><a name="setUseQueryString"></a>void setUseQueryString(<span class="parameter">use_query_string</span>)</h4>
+ <p>Dynamically modifies the use_query_string setting. When true this forces SWFUpload to send post parameters on the query string rather than in the post. The use_query_string parameter should be a boolean true or false.</p>
+
+ <h4><a name="setDebugEnabled"></a>void setDebugEnabled(<span class="parameter">debug_enabled</span>)</h4>
+ <p>Dynamically enables or disables debug output. The debug_enabled parameter should be a boolean true or false.</p>
+
+ <h4><a name="setButtonImageURL"></a>void setButtonImageURL(<span class="parameter">url</span>)</h4>
+ <p>Dynamically change the image used in the Flash Button. The image url must be relative to the swfupload.swf file, an absolute path (e.g., starting with a /), or
+ a fully qualified url (e.g., http://www.swfupload.org/buttonImage.png). Any image format supported by Flash can be loaded. The most notable formats are jpg, gif, and png.</p>
+
+ <p>The button image is expected to be a button sprite (or a single image file with several images stacked together). The image will be used to represent
+ all the button states by moving the image up or down to only display the needed portion. These states include: normal, hover, click, disabled. See the sample button images.</p>
+
+ <h4><a name="setButtonDimensions"></a>void setButtonDimensions(<span class="parameter">width</span>, <span class="parameter">height</span>)</h4>
+ <p>Dynamically change the Flash button's width and height. The values should be numeric and should not include any units. The height value should
+ be 1/4th of the total button image height so the button state sprite images can be displayed correctly</p>
+
+ <h4><a name="setButtonText"></a>void setButtonText(<span class="parameter">text</span>)</h4>
+ <p>Sets the text that should be displayed over the Flash button. Text that is too large and overflows the button size will be clipped.</p>
+ <p>The text can be styled using HTML supported by the Flash Player (<a target="_blank" href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/text/TextField.html#htmlText">Adobe Documentation</a>)</p>
+
+ <h4><a name="setButtonTextStyle"></a>void setButtonTextStyle(<span class="parameter">css_style_text</span>)</h4>
+ <p>Sets the CSS styles used to style the Flash Button Text. CSS should be formatted according to the Flash Player documentation (<a target="_blank" href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/text/StyleSheet.html">Adobe Documentation</a>)</p>
+ <p>Style classes defined here can then be referenced by HTML in the button_text setting.</p>
+
+ <h4><a name="setButtonTextPadding"></a>void setButtonTextPadding(<span class="parameter">left</span>, <span class="parameter">top</span>)</h4>
+ <p>Sets the top and left padding of the Flash button text. The values may be negative.</p>
+
+ <h4><a name="setButtonDisabled"></a>void setButtonDisabled(<span class="parameter">isDisabled</span>)</h4>
+ <p>When 'true' changes the Flash Button state to disabled and the BUTTON_ACTION is ignored. The mouseClick event is always fired when the button is disabled.</p>
+
+ <h4><a name="setButtonAction"></a>void setButtonAction(<span class="parameter">buttonAction</span>)</h4>
+ <p>Sets the action taken when the Flash button is clicked. Valid action values are taken from the BUTTON_ACTION constants.</p>
+
+ <h4><a name="setButtonCursor"></a>void setButtonCursor(<span class="parameter">buttonCursor</span>)</h4>
+ <p>Sets the mouse cursor shown when hovering over the Flash button. Valid cursor values are taken from the CURSOR constants.</p>
+
+
+
+ <h3><a name="events"></a>Events</h3>
+ <p>SWFUpload fires various events during its operation. These events can be handled by the developer to update the UI, change behavior, or report errors.</p>
+ <p>All SWFUpload events are called in the context of a SWFUpload instance. This means that the 'this' object refers to the SWFUpload instance that
+ fired the event.</p>
+
+ <p>SWFUpload events should be set only by assigning the event handler function in the settings object during object initialization. You should not override the
+ internal functions belonging to the SWFUpload.prototype object.</p>
+
+ <p>During a file upload events are usually called in this order (the Upload Event Chain):</p>
+ <ul>
+ <li>uploadResizeStart</li>
+ <li>uploadStart</li>
+ <li>uploadProgress (called over and over again as the file uploads)</li>
+ <li>uploadError (called if some kind of error occurs, the file is canceled or stopped)</li>
+ <li>uploadSuccess (the upload finished successfully, data returned from the server is available)</li>
+ <li>uploadComplete (the upload is complete and SWFUpload is ready to start the next file)</li>
+ </ul>
+
+ <h4><a name="flashReady"></a><span class="function">flashReady()</span></h4>
+ <p>flashReady is an internal event that should not be overwritten. It is called by the Flash Control to notify SWFUpload that the Flash
+ movie has loaded and is ready to accept commands.</p>
+
+ <h4><a name="swfUploadPreload"></a><span class="function">swfUploadPreload()</span></h4>
+ <p>
+ The swfUploadPreload event is fired after SWFUpload has determined what features are available but before the Flash Movie is loaded. Returning false from this event prevents SWFUpload from loading.
+ This event can be used to gracefully degrade if the client's browser does not support the features needed.
+ </p>
+ <p>Set using the swfupload_preload_handler setting.</p>
+
+ <h4><a name="swfUploadLoadFailed"></a><span class="function">swfUploadLoadFailed()</span></h4>
+ <p>The xxxxxx event is fired if SWFUpload determines it cannot load or an exception occurs while added the Flash Movie to the document. SWFUpload may not be able to load because the Flash Player is not installed or a version older than 9.0.28 is installed</p>
+ <p>Set using the swfupload_load_failed_handler setting.</p>
+
+ <h4><a name="swfUploadLoaded"></a><span class="function">swfUploadLoaded()</span></h4>
+ <p>The swfUploadLoaded event is fired by flashReady. It is settable. swfUploadLoaded is called to let you know that it is safe to call SWFUpload methods.</p>
+ <p>Set using the swfupload_loaded_handler setting.</p>
+
+ <h4><a name="mouseClick"></a><span class="function">mouseClick()</span></h4>
+ <p>mouseClick is fired when the button is clicked and the button_action setting is set to SWFUpload.BUTTON_ACTION.NONE or the button is disabled. This event is not fired for other button_action settings and the button is enabled.</p>
+ <p>Set using the mouse_click_handler setting.</p>
+
+ <h4><a name="mouseOver"></a><span class="function">mouseOver()</span></h4>
+ <p>mouseOver is fired when the cursor moves over any part of the Flash Movie.</p>
+ <p>Set using the mouse_over_handler setting.</p>
+
+ <h4><a name="mouseOut"></a><span class="function">mouseOut()</span></h4>
+ <p>mouseOut is fired when the cursor moves off the Flash Movie.</p>
+ <p>Set using the mouse_out_handler setting.</p>
+
+ <h4><a name="fileDialogStart"></a><span class="function">fileDialogStart(<span class="parameter"></span>)</span></h4>
+ <p>fileDialogStart is fired after selectFile for selectFiles is called. This event is fired immediately before the File Selection Dialog
+ window is displayed. However, the event may not execute until after the Dialog window is closed.</p>
+ <p>Set using the file_dialog_start_handler setting.</p>
+
+ <h4><a name="fileQueued"></a><span class="function">fileQueued(<span class="parameter">file object</span>)</span></h4>
+ <p>The fileQueued event is fired for each file that is queued after the File Selection Dialog window is closed.</p>
+ <p>Set using the file_queued_handler setting.</p>
+
+ <h4><a name="fileQueueError"></a><span class="function">fileQueueError(<span class="parameter">file object</span>, <span class="parameter">error code</span>, <span class="parameter">message</span>)</span></h4>
+ <p>The fileQueueError event is fired for each file that was not queued after the File Selection Dialog window is closed. A file may not be queued
+ for several reasons such as, the file exceeds the file size, the file is empty or a file or queue limit has been exceeded.</p>
+ <p>The cause of the queue error is specified by the error code parameter. The error code corresponds to a SWFUpload.QUEUE_ERROR constant.</p>
+ <p>Set using the file_queue_error_handler setting.</p>
+
+ <h4><a name="fileDialogComplete"></a><span class="function">fileDialogComplete(<span class="parameter">number of files selected</span>, <span class="parameter">number of files queued</span>, <span class="parameter">total number of files in the queued</span>)</span></h4>
+ <p>The fileDialogComplete event fires after the File Selection Dialog window has been closed and all the selected files have been processed. The 'number of files queued' argument indicates the number of files that were queued from the dialog selection (as opposed to the number of files in the queue).</p>
+ <p>If you want file uploading to begin automatically this is a good place to call 'this.startUpload()'</p>
+ <p>Set using the file_dialog_complete_handler setting.</p>
+
+ <h4><a name="uploadResizeStart"></a><span class="function">uploadResizeStart(<span class="parameter">file object</span>, <span class="parameter">width</span>, <span class="parameter">height</span>, <span class="parameter">encoding</span>, <span class="parameter">quality</span>)</span></h4>
+ <p>uploadResizeStart is called immediately before an image is resized. Resizing does not provide any progress events but can take some time due to re-encoding of the file. If an error occurs during resizing the uploadError event is fired.</p>
+
+ <p>When resizing is complete SWFUpload moves on to the uploadStart event and continues using the normal event chain.</p>
+
+ <h4><a name="uploadStart"></a><span class="function">uploadStart(<span class="parameter">file object</span>)</span></h4>
+ <p>uploadStart is called immediately before the file is uploaded. This event provides an opportunity to perform any last minute validation, add post
+ params or do any other work before the file is uploaded.</p>
+
+ <p>The upload can be cancelled by returning 'false' from uploadStart. If you return 'true' or do not return any value then the upload proceeds. Returning
+ 'false' will cause an uploadError event to fired.</p>
+
+ <p>Set using the upload_start_handler setting.</p>
+
+ <h4><a name="uploadProgress"></a><span class="function">uploadProgress(<span class="parameter">file object</span>, <span class="parameter">bytes complete</span>, <span class="parameter">total bytes</span>)</span></h4>
+ <p>The uploadProgress event is fired periodically by the Flash Control. This event is useful for providing UI updates on the page.</p>
+ <p><strong>Note:</strong> The Linux Flash Player fires a single uploadProgress event after the entire file has been uploaded. This is a bug in
+ the Linux Flash Player that we cannot work around.</p>
+ <p>Set using the upload_progress_handler setting.</p>
+
+ <h4><a name="uploadError"></a><span class="function">uploadError(<span class="parameter">file object</span>, <span class="parameter">error code</span>, <span class="parameter">message</span>)</span></h4>
+ <p>The uploadError event is fired any time an upload is interrupted or does not complete successfully. The error code parameter indicates the type of error
+ that occurred. The error code parameter specifies a constant in SWFUpload.UPLOAD_ERROR.</p>
+ <p>Stopping, Cancelling or returning 'false' from uploadStart will cause uploadError to fire. Upload error will not fire for files that are cancelled
+ but still waiting in the queue.</p>
+ <p>Set using the upload_error_handler setting.</p>
+
+ <h4><a name="uploadSuccess"></a><span class="function">uploadSuccess(<span class="parameter">file object</span>, <span class="parameter">server data</span>, <span class="parameter">received response</span>)</span></h4>
+ <p>uploadSuccess is fired when the entire upload has been transmitted and the server returns a HTTP 200 status code. Any data outputted by the server is available
+ in the server data parameter.</p>
+
+ <p>
+ Due to some bugs in the Flash Player the server response may not be acknowledged and no uploadSuccess event is fired by Flash. In this case the
+ assume_success_timeout setting is checked to see if enough time has passed to fire uploadSuccess anyway. In this case the received response parameter will be false.
+ </p>
+
+ <p>
+ The http_success setting allows uploadSuccess to be fired for HTTP status codes other than 200. In this case no server data is available from the Flash Player.
+ </p>
+
+ <p>At this point the upload is not yet complete. Another upload cannot be started from uploadSuccess.</p>
+
+ <p>Set using the upload_success_handler setting.</p>
+
+ <h4><a name="uploadComplete"></a><span class="function">uploadComplete(<span class="parameter">file object</span>)</span></h4>
+ <p>uploadComplete is always fired at the end of an upload cycle (after uploadError or uploadSuccess). At this point the upload is complete and
+ another upload can be started.</p>
+ <p>If you want the next upload to start automatically this is a good place to call this.uploadStart(). Use caution when calling uploadStart inside
+ the uploadComplete event if you also have code that cancels all the uploads in a queue.</p>
+ <p>Set using the upload_complete_handler setting.</p>
+
+ <h4><a name="debug"></a><span class="function">debug(<span class="parameter">message</span>)</span></h4>
+ <p>The debug event is called by the SWFUpload library and the Flash Control when the debug setting is set to 'true'. If the debug
+ event is not overridden then SWFUpload writes debug messages to the SWFUpload console (a text box dynamically added to the end of the page body).</p>
+ <p>Set using the debug_handler setting.</p>
+
+ <h3><a name="utility"></a>SWFUpload Utility Objects</h3>
+ <h4><a name="settingsobject"></a>Settings object</h4>
+ <p>The settings object is a JavaScript object that provides the settings for the SWFUpload instance. <strong>Each setting should only appear once.</strong> Many settings
+ are optional and provide suitable default values if omitted. See the setting details for required and optional settings.</p>
+ <p><strong>Example:</strong></p>
+ <code>{
+ upload_url : "http://www.swfupload.org/upload.php",
+ flash_url : "http://www.swfupload.org/swfupload.swf",
+ flash9_url : "http://www.swfupload.org/swfupload_fp9.swf",
+
+ file_post_name : "Filedata",
+ post_params : {
+ "post_param_name_1" : "post_param_value_1",
+ "post_param_name_2" : "post_param_value_2",
+ "post_param_name_n" : "post_param_value_n"
+ },
+ use_query_string : false,
+ requeue_on_error : false,
+ http_success : [201, 202],
+ assume_success_timeout : 0,
+ file_types : "*.jpg;*.gif",
+ file_types_description: "Web Image Files",
+ file_size_limit : "1024",
+ file_upload_limit : 10,
+ file_queue_limit : 2,
+
+ debug : false,
+
+ prevent_swf_caching : false,
+ preserve_relative_urls : false,
+
+ button_placeholder_id : "element_id",
+ button_image_url : "http://www.swfupload.org/button_sprite.png",
+ button_width : 61,
+ button_height : 22,
+ button_text : "&lt;b&gt;Click&lt;/b&gt; &lt;span class="redText"&gt;here&lt;/span&gt;",
+ button_text_style : ".redText { color: #FF0000; }",
+ button_text_left_padding : 3,
+ button_text_top_padding : 2,
+ button_action : SWFUpload.BUTTON_ACTION.SELECT_FILES,
+ button_disabled : false,
+ button_cursor : SWFUpload.CURSOR.HAND,
+ button_window_mode : SWFUpload.WINDOW_MODE.TRANSPARENT,
+
+ swfupload_loaded_handler : swfupload_loaded_function,
+ mouse_click_handler : mouse_click_function,
+ mouse_over_handler : mouse_over_function,
+ mouse_out_handler : mouse_out_function,
+ file_dialog_start_handler : file_dialog_start_function,
+ file_queued_handler : file_queued_function,
+ file_queue_error_handler : file_queue_error_function,
+ file_dialog_complete_handler : file_dialog_complete_function,
+ upload_start_handler : upload_start_function,
+ upload_progress_handler : upload_progress_function,
+ upload_error_handler : upload_error_function,
+ upload_success_handler : upload_success_function,
+ upload_complete_handler : upload_complete_function,
+ debug_handler : debug_function,
+
+ custom_settings : {
+ custom_setting_1 : "custom_setting_value_1",
+ custom_setting_2 : "custom_setting_value_2",
+ custom_setting_n : "custom_setting_value_n",
+ }
+}</code>
+ <h4><a name="settingsdescription"></a>Settings Description</h4>
+
+ <h5>upload_url</h5>
+ <p>The upload_url setting accepts a full, absolute, or relative target URL for the uploaded file. Relative URLs should be relative to document. The upload_url should be in the same domain as the Flash Control for best compatibility.</p>
+ <p>If the preserve_relative_urls setting is false SWFUpload will convert the relative URL to an absolute URL to avoid the URL being interpreted differently by the Flash Player on different platforms. If you disable SWFUploads conversion of the URL relative URLs should be relative to the swfupload.swf file.</p>
+
+ <h5>file_post_name</h5>
+ <p>The file_post_name allows you to set the value name used to post the file. This is not related to the file name.
+ The default value is 'Filedata'. For maximum compatibility it is recommended that the default value is used.</p>
+
+ <h5>post_params</h5>
+ <p>
+ The post_params setting defines the name/value pairs that will be posted with each uploaded file. This setting accepts a simple JavaScript object.
+ Multiple post name/value pairs should be defined as demonstrated in the sample settings object. Values must be either strings or numbers (as interpreted by the JavaScript typeof function).
+ </p>
+ <p>Note: Flash Player 8 does not support sending additional post parameters. SWFUpload will automatically send the post_params as part of the query string.</p>
+
+ <h5>use_query_string</h5>
+ <p>
+ The use_query_string setting may be true or false. This value indicates whether SWFUpload should send the post_params and file params on the query string or the post. This setting was introduced in SWFUpload v2.1.0.
+ </p>
+
+ <h5>preserve_relative_urls</h5>
+ <p>A boolean value that indicates whether SWFUpload should attempt to convert relative URLs used by the Flash Player to absolute URLs. If set to true SWFUpload will not modify any URLs. The default value is false.</p>
+
+ <h5>requeue_on_error</h5>
+ <p>
+ The requeue_on_error setting may be true or false. When this setting is true any files that has an
+ uploadError (excluding fileQueue errors and the FILE_CANCELLED uploadError) is returned to the front of
+ the queue rather than being discarded. The file can be uploaded again if needed. To remove the file from the
+ queue the cancelUpload method must be called.
+ </p>
+ <p>
+ All the events associated with a failed upload are still called and so the requeuing the failed upload can conflict
+ with the Queue Plugin (or custom code that uploads the entire queue). Code that automatically uploads the next file
+ in the queue will upload the failed file over and over again if care is not taken to allow the failing upload to be
+ cancelled.
+ </p>
+ <p>
+ This setting was introduced in SWFUpload v2.1.0.
+ </p>
+
+ <h5>http_success</h5>
+ <p>
+ An array that defines the HTTP Status Codes that will trigger success. 200 is always a success. Also, only the 200 status code provides the serverData.
+ </p>
+ <p>
+ When returning and accepting an HTTP Status Code other than 200 it is not necessary for the server to return content.
+ </p>
+
+ <h5>assume_success_timeout</h5>
+ <p>
+ The number of seconds SWFUpload should wait for Flash to detect the server's response after the file has finished uploading. This setting allows you to
+ work around the Flash Player bugs where long running server side scripts causes Flash to ignore the server response or the Mac Flash Player bug that ignores
+ server responses with no content.
+ </p>
+ <p>
+ Testing has shown that Flash will ignore server responses that take longer than 30 seconds after the last uploadProgress event.
+ </p>
+ <p>
+ A timeout of zero (0) seconds disables this feature and is the default value. SWFUpload will wait indefinitely for the Flash Player to trigger the uploadSuccess event.
+ </p>
+
+ <h5>file_types</h5>
+ <p>
+ The file_types setting accepts a semi-colon separated list of file extensions that are allowed to be selected by the user. Use '*.*' to allow all file types.
+ </p>
+
+ <h5>file_types_description</h5>
+ <p>
+ A text description that is displayed to the user in the File Browser dialog.
+ </p>
+
+ <h5>file_size_limit</h5>
+ <p>
+ The file_size_limit setting defines the maximum allowed size of a file to be uploaded. This setting accepts a value and unit.
+ Valid units are B, KB, MB and GB. If the unit is omitted default is KB. A value of 0 (zero) is interpreted as unlimited.
+ </p>
+ <p>
+ Note: This setting only applies to the user's browser. It does not affect any settings or limits on the web server.
+ </p>
+
+ <h5>file_upload_limit</h5>
+ <p>
+ Defines the number of files allowed to be uploaded by SWFUpload. This setting also sets the upper bound of the file_queue_limit
+ setting. Once the user has uploaded or queued the maximum number of files she will no longer be able to queue additional files. The
+ value of 0 (zero) is interpreted as unlimited. Only successful uploads (uploads the trigger the uploadSuccess event) are counted
+ toward the upload limit. The setStats function can be used to modify the number of successful uploads.
+ </p>
+ <p>Note: This value is not tracked across pages and is reset when a page is refreshed. File quotas should be managed by the web server.</p>
+
+ <h5>file_queue_limit</h5>
+ <p>
+ Defines the number of unprocessed files allowed to be simultaneously queued. Once a file is uploaded, errored, or cancelled a new
+ files can be queued in its place until the queue limit has been reached. If the upload limit (or remaining uploads allowed) is less
+ than the queue limit then the lower number is used.
+ </p>
+
+ <h5>flash_url</h5>
+ <p>
+ The full, absolute, or relative URL to the Flash Control swf file. This setting cannot be changed once the SWFUpload has been
+ instantiated. Relative URLs are relative to the page URL.
+ </p>
+
+ <h5>flash9_url</h5>
+ <p>
+ <strong>(Added in v2.5.0)</strong> the full, absolute, or relative URL to the Flash Control swf file that supports Flash Player 9.
+ </p>
+
+ <h5>flash_width</h5>
+ <p>
+ <strong>(Removed in v2.1.0)</strong> Defines the width of the HTML element that contains the flash. Some browsers do not function correctly if this setting is less than 1 px.
+ This setting is optional and has a default value of 1px.
+ </p>
+
+ <h5>flash_height</h5>
+ <p>
+ <strong>(Removed in v2.1.0)</strong> Defines the height of the HTML element that contains the flash. Some browsers do not function correctly if this setting is less than 1 px.
+ This setting is optional and has a default value of 1px.
+ </p>
+
+ <h5>flash_color</h5>
+ <p>
+ <strong>Removed in v2.2.0</strong> This setting sets the background color of the HTML element that contains the flash. The default value is '#FFFFFF'.
+ </p>
+ <p>
+ Note: This setting may not be effective in "skinning" 1px flash element in all browsers.
+ </p>
+
+ <h5>prevent_swf_caching</h5>
+ <p>
+ <strong>Added in v2.2.0</strong> This boolean setting indicates whether a random value should be added to the Flash URL in an attempt to
+ prevent the browser from caching the SWF movie. This works around a bug in some IE-engine based browsers.
+ </p>
+ <p>Note: The algorithm for adding the random number to the URL is dumb and cannot handle URLs that already have some parameters.</p>
+
+ <h5>debug</h5>
+ <p>A boolean value that defines whether the debug event handler should be fired.</p>
+
+ <h5>button_placeholder_id</h5>
+ <p><strong>(Added in v2.2.0)</strong> This required setting sets the ID of DOM element that will be <em>replaced</em> by the Flash Button. This setting overrides the button_placeholder setting. The Flash button can be styled using the CSS class 'swfupload'.</p>
+
+ <h5>button_placeholder</h5>
+ <p><strong>(Added in v2.2.0)</strong> This required setting sets the DOM element that will be <em>replaced</em> by the Flash Button. This setting is only applied if the button_placeholder_id is not set. The Flash button can be styled using the CSS class 'swfupload'.</p>
+
+ <h5>button_image_url</h5>
+ <p><strong>(Added in v2.2.0)</strong> Fully qualified, absolute or relative URL to the image file to be used as the Flash button. Any Flash supported image file format can be used (another SWF file or gif, jpg, or png).</p>
+ <p>This URL is affected by the preserve_relative_urls setting and should follow the same rules as the upload_url setting.</p>
+
+ <p>The button image is treated as a sprite. There are 4 button states that must be represented by the button image. Each button state image
+ should be stacked above the other in this order: normal, hover, down/click, disabled.</p>
+
+ <h5>button_width</h5>
+ <p><strong>(Added in v2.2.0)</strong> A number defining the width of the Flash button.</p>
+
+ <h5>button_height</h5>
+ <p><strong>(Added in v2.2.0)</strong> A number defining the height of the Flash button. This value should be 1/4th of the height or
+ the button image.</p>
+
+ <h5>button_text</h5>
+ <p><strong>(Added in v2.2.0)</strong> Plain or HTML text that is displayed over the Flash button. HTML text can be further styled using CSS
+ classes and the button_text_style setting. See <a target="_blank" href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/text/TextField.html#htmlText">Adobe's Flash documentation</a> for details.</p>
+
+ <h5>button_text_style</h5>
+ <p><strong>(Added in v2.2.0)</strong> CSS style string that defines how the button_text is displayed.
+ See <a target="_blank" href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/text/StyleSheet.html">Adobe's Flash documentation</a> for details.</p>
+
+ <h5>button_text_top_padding</h5>
+ <p><strong>(Added in v2.2.0)</strong> Used to vertically position the Flash button text. Negative values may be used.</p>
+
+ <h5>button_text_left_padding</h5>
+ <p><strong>(Added in v2.2.0)</strong> Used to horizontally position the Flash button text. Negative values may be used.</p>
+
+ <h5>button_action</h5>
+ <p><strong>(Added in v2.2.0)</strong> Defines the action taken when the Flash button is clicked. Valid action values can be found in the swfupload.js file under the BUTTON_ACTION object.</p>
+
+ <h5>button_disabled</h5>
+ <p><strong>(Added in v2.2.0)</strong> A boolean value that sets whether the Flash button is in the disabled state. When in the disabled state the button will not execute any actions.</p>
+
+ <h5>button_cursor</h5>
+ <p><strong>(Added in v2.2.0)</strong> Used to define what type of mouse cursor is displayed when hovering over the Flash button.</p>
+
+ <h5>button_window_mode</h5>
+ <p><strong>(Added in v2.2.0)</strong> Sets the WMODE property of the Flash Movie. Valid values are available in the SWFUpload.WINDOW_MODE constants.</p>
+
+ <h5>custom_settings</h5>
+ <p>
+ The custom_settings setting allows developers to safely attach additional information to a SWFUpload instance without
+ worrying about affecting internal SWFUpload values or changes in new SWFUpload versions. This setting accepts a JavaScript
+ object.
+ </p>
+ <p>
+ Once instantiated the custom settings are accessed in the 'customSettings' property of the SWFUpload instance.
+ </p>
+ <code>var swfu = new SWFUpload({
+ custom_settings : {
+ "My Setting" : "This is my setting",
+ myothersetting : "This is my other setting",
+ integer_setting : 100,
+ a_dom_setting : document.getElementById("some_element_id")
+ }
+});
+
+var my_setting = swfu.customSettings["My Setting"]);
+swfu.customSettings["My Setting"] = "This is my new setting";
+swfu.customSetting.myothersetting = "another new value";
+swfu.customSetting.integer_setting += 25;
+swfu.customSetting["a_dom_setting"].style.visibility = "hidden";</code>
+
+ <h5>Event Handlers</h5>
+ <p>
+ The remaining settings define the event handlers called by SWFUpload during its operation. JavaScript functions should
+ be defined to handle these events as needed.
+ </p>
+
+
+ <h4><a name="supportobject"></a>Support Object</h4>
+ <p>The support object is a property of a SWFUpload instance and identifies what features SWFUpload can support based on the Flash Player version installed in the client browser.</p>
+ <code>{
+ load : bool, // Indicates if SWFupload is able to load based of Flash Player version
+ imageResize : bool, // Indicates of Flash Player 10 or later is installed and SWFUpload supports client side resizing and uploading of images.
+}</code>
+
+ <h4><a name="fileobject"></a>File Object</h4>
+ <p>The file object is passed to several event handlers. It contains information about the file. Some operating systems do not fill in all the values (this
+ is especially true for the createdate and modificationdate values).</p>
+ <code>{
+ id : string, // SWFUpload file id, used for starting or cancelling and upload
+ index : number, // The index of this file for use in getFile(i)
+ name : string, // The file name. The path is not included.
+ size : number, // The file size in bytes
+ type : string, // The file type as reported by the client operating system
+ creationdate : Date, // The date the file was created
+ modificationdate : Date, // The date the file was last modified
+ filestatus : number, // The file's current status. Use SWFUpload.FILE_STATUS to interpret the value.
+ post : object // The post params that will be sent with this file (compiled from the post_params setting and any params added with the addFileParam function
+
+}</code>
+
+ <h4><a name="statsobject"></a>Stats Object</h4>
+ <p>The Stats object provides information about the upload queue.</p>
+ <p>That stats object contains the following properties:</p>
+ <code>{
+ in_progress : number // 1 or 0 indicating if a file upload is currently in progress
+ files_queued : number // The number of files currently in the queue
+ successful_uploads : number // The number of files that have uploaded successfully (caused uploadSuccess to be fired)
+ upload_errors : number // The number of files that have had errors (excluding cancelled files)
+ upload_cancelled : number // The number of files that have been cancelled
+ queue_errors : number // The number of files that caused fileQueueError to be fired
+}</code>
+ <p>All these values can be updated using setStats() except the <em>in_progress</em> and <em>files_queued</em> values.</p>
+
+ <h2><a name="plugins"></a>SWFUpload Plug-ins</h2>
+
+ <p>With SWFUpload v2.0 several plugins have been introduced. They are provided to help with common tasks associated with implementing SWFUpload.</p>
+ <p>Currently most of the documentation for using the plugins is contained in the plugin JavaScript file.</p>
+
+ <h3>SWFObject</h3>
+ <p>
+ The SWFObject plugin uses the <a href="http://code.google.com/p/swfobject/">SWFObject library</a> to handle the embedding
+ of the SWFUpload Flash Component into the page.
+ </p>
+ <p>
+ This plugin also provides support for Document Ready loading and Flash Version Detection. Usage details are documented
+ in the plugin file itself. You should not use the SWFObject's Document Ready loading mixed with another libraries DOMReady. Use
+ one or the other but not both.
+ </p>
+
+ <p><strong>Flash Player 10: </strong> Because Flash Player 10 requires the SWFUpload swf to act is a button the movie must be visible in order
+ for it to load. If the button_placeholder_id is set to an element that is hidden (visibility set to hidden or display set to none) SWFUpload will
+ fail to load.</p>
+
+ <h3>Cookies</h3>
+ <p>In response to the Flash Cookie Bug the Cookies Plugin automatically retrieves your browser's cookies and sends them
+ with the upload. The are sent as POST or GET variables to the upload url.</p>
+
+ <p>Note that this plugin sends the cookies name/values in the POST or GET. On the server side they will not be accessible as cookies. Some frameworks that
+ automatically check cookies for session or authentication values still will not be able to find the values.</p>
+
+ <h3>Queue Handling</h3>
+ <p>This plugin provides Queue Handling features such as entire queue uploading, entire queue cancelling and automatic starting of uploads after being queued.</p>
+
+
+ <h3>Speed</h3>
+ <p>This Plugin extends the 'file' object with several properties that describe the current upload. This includes current speed, average speed, elapsed time, remaining time and more.</p>
+
+
+ <h2><a name="knownissues"></a>Known Issues</h2>
+ <p>The Flash Player and many Browsers have bugs that have a direct impact on the performance of SWFUpload. While we have worked
+ hard to get around many issues but there are some things that we cannot fix.</p>
+
+ <h3>Cancelling in Linux</h3>
+ <p>Older Flash 9 Players for Linux cause the browser to crash if an upload is cancelled. Newer Flash 9 Players behave better.</p>
+
+ <h3>Upload Progress in Linux</h3>
+ <p>The Flash Player in Linux sends a single uploadProgress event after the file has finished uploading.</p>
+ <p>In some distributions the entire browser locks up while the upload is in progress.</p>
+
+ <h3>Upload Progress in OS X</h3>
+ <p>There have been some reports that uploadProgress events are not fired in MAC Flash Players. The specifics haven't been pinned down but be aware of the possible issue.</p>
+
+ <h3>MIME Type</h3>
+ <p>The Flash Player uploads all files with a mime type of <em>application/octet-stream</em> regardless of the file's actual mime type.</p>
+
+ <h3>Maximum number of selected files</h3>
+ <p>The Flash Player does not impose a maximum number of selected files. However, it builds a selected files string which does have a maximum length.
+ The string is built using the file's name and the separator [quote][space][quote]. The total number of files selected is determined by the sum
+ of the lengths of the file names and a prefixed and postfixed [quote] character (2 characters) and the number of files selected minus one times 3 (for the separator string)</p>
+
+ <p>This limitation may vary from system to system. If a user selects too many files they will be receive a Flash Player generated warning message and will
+ be left at the File Selection Dialog.</p>
+
+ <h3>Proxies</h3>
+ <p>The Flash Player may not properly use proxies. It does not handle authenticating proxies well (if at all) and will some-times crash.</p>
+ <p>Some anti-virus software uses a proxy to scan uploads and cause SWFUpload to believe the entire file has been uploaded. SWFUpload will fire uploadProgress events very quickly
+ until it reaches 100% and will then seem to pause until the proxy completes uploading the file to the server.</p>
+ <p><strong>Kaspersky Anti-Virus:</strong> Kaspersky (and other) Anti-Virus suites implement a client-side proxy that intercepts and scans outgoing data. SWFUpload
+ cannot detect the presence of proxy servers. These types of proxy servers accept the entire upload very quickly and they wait while the data is scanned and transmitted
+ to the original destination. The Flash Player times out the connection (because of appearent inactivity) and returns a #2038 error. SWFUpload fires an uploadError event.</p>
+
+ <h3>Apache mod_security</h3>
+ <p>Apache's mod_security validates POST to the server. Flash Player has implemented an edge case (there is argument as to whether it is invalid or note)
+ POST for file uploads and so servers implementing
+ mod_security will reject the upload. mod_security can be disabled using your .htaccess file</p>
+
+ <h3>SSL</h3>
+ <p>There have been some reports that the Flash Player cannot upload through SSL.
+ The issue has not been pinned down but uploading over SSL may be unreliable. There especially seems to be an issue with
+ using self-signed certificates.</p>
+ <p>Also, SSL tickets from untrusted Certificate Authorities (CA) do not work as Flash does not provide a method for accepting the certificate. It has been noted that, like the cookie bug,
+ that Flash Player on Windows obtains its trusted CA list from Internet Explorer regardless of the browser in use.</p>
+
+ <h3>Authentication</h3>
+ <p>HTTP Authentication is not well supported by the Flash Player. Later versions of Flash Player behave better. Old version of Flash Player would crash the browser.</p>
+
+ <h3>Prematurely terminated connections</h3>
+ <p>Prematurely ending the response (such as a Response.end() in ASP.Net) can sometimes cause successful uploads to be reported as failed.</p>
+
+ <h3>Filedata POST name in Linux</h3>
+ <p>Changing the Filedata value (file_post_name setting) is ignored in Linux Flash Players.</p>
+
+ <h3>Cookie bug</h3>
+ <p>On Windows the Non-IE Flash Player plugin (FireFox, Opera, Safari, etc) will send the IE cookies regardless of the browser used. This breaks authentication and sessions for many server-side scripting technologies.</p>
+ <p>Developers should manually pass Session and Authentication cookie information and manually restore Sessions on the Server Side if they wish to use Sessions</p>
+ <p>The SWFUpload package contains work-around sample code for PHP and ASP.Net</p>
+
+ <h3>ExternalInterface bugs</h3>
+ <p>Flash Player does not properly escape data when communication with the browser/JavaScript. SWFUpload goes to great lengths to work-around this issue. If this
+ bug is fixed in future Flash Players/Browsers then SWFUpload will send extra escaped data.</p>
+
+ <h3>Server Data length bugs</h3>
+ <p>Very long server data is corrupted on Mac and Linux Flash Players. Server data will be truncated, garbled, and/or repeated. We recommend
+ keeping data returned from the server short and concise.</p>
+
+ <h3>Avant Browser</h3>
+ <p>For some users the Avant Browser does not work with SWFUpload after the Flash Control has been cached. This has been reproduced by the
+ SWFUpload developers but the Avant Browser developers did not experience any problems.</p>
+ <p>When the page is reloaded SWFUpload loads and fires the swfupload_loaded event. However, none of the ExternalInterface callback functions are defined
+ on the movie element. SWFUpload v2.0.2 has added checks which prevent swfupload_loaded from firing if the callback functions are not detected.</p>
+
+ <p><strong>SWFUpload v2.2.0 added the prevent_swf_caching setting that attempts to work around this issue.</strong></p>
+
+ <h3>File Dialog &amp; Page Changing</h3>
+ <p>Leaving or reloading the current page while the File Browser Dialog window is open will cause the browser to crash (all browsers, all OSs). Most commonly this is caused by failing to
+ cancel a click event on an &lt;a&gt; tag where the onclick event calls the selectFile or selectFiles function.</p>
+
+ <h3>Long Running Upload Scripts</h3>
+ <p>After Flash has uploaded the file to the webserver the upload script is executed. This script handles the file whether that means saving it, creating a thumbnail, scanning for viruses, etc.
+ If the upload script does not return any data within 30 seconds Flash will disconnect and return an IO Error. You can prevent this by returning characters or data while
+ the script runs (if possible). For PHP, the script continues to run and complete successfully even though Flash has terminated the connection. Any data returned
+ by the script after Flash has disconnected is lost.</p>
+
+ <h3>WMODE / BUTTON_WINDOW_MODE</h3>
+
+ <p>In some browsers the selected WMODE (which is set using the BUTTON_WINDOW_MODE) can prevent the Flash Control from loading
+ if the control is not on screen. The control will finally load once the user scrolls the page so the control becomes visible.</p>
+
+ <p>This behavior can adversely affect the SWFObject plugin. No SWFUpload events will be fire and the button image will not be
+ loaded until the control becomes visible.</p>
+
+ <p>On some systems (Linux is affected) when the WMODE is transparent Flash opens the File Dialog window behind the browser window.</p>
+
+ <h3>Memory Leaks</h3>
+ <p>Some browsers (especially IE) cannot recover memory used by the Flash Player when JavaScript communication via the ExternalInterface classes is used (like in SWFUpload).
+ Creating many SWFUpload instances and/or reloading the page several times will cause the browser to consume more and more memory until it crashes or otherwise harms the
+ system.</p>
+
+ <p>In v2.2.0 SWFUpload we have implemented some preventative measures. Some of these measures are pro-active but it is still recommended that you
+ call the destroy method when the page unloads. If you are using hundreds of SWFUpload instances on a page you should use caution and test
+ carefully for memory leaks.</p>
+
+ <h3>Other Mac Issues</h3>
+ <ul>
+ <li>
+ Content must be returned by the server or the Mac Flash Player will not trigger the uploadSuccess event. We have added the assume_success_timeout setting to help work around this.
+ But in general it is simply easier and more reliable to return a short string after the upload is complete.
+ </li>
+ <li>
+ Users have reported that uploading to subdomains does not work with the Mac Flash Player.
+ </li>
+ <li>
+ Users have reported that pages that redirect (HTTP Status 302) are not handled by the Mac Flash Player. Windows
+ clients seem to handle this issue. 302 redirects are used in many authentication schemes and MVC frameworks.
+ </li>
+ <li>
+ The flash documentation states that on OS early than OS X 10.3 the bytes loaded is always reported as -1. SWFUpload converts
+ this to 0 but the total bytes will never be sent and 100% won't be reached. The UI should be updated to display 100% complete in
+ uploadSuccess or uploadComplete events to maintain a consistent UI.
+ </li>
+ <li>
+ Some users have reported issues if there is a space character in the upload_url for the Mac Flash Player. Avoid spaces or try replacing them with + or %20.
+ </li>
+ <li>
+ Users have reported that the Flash Player for Mac adds the PORT to the HTTP HOST header (e.g., http://www.example.com:80). If you are
+ checking this variable in your server-side script be aware of the possible issue.
+ </li>
+ <li>
+ Files that contain only a resource fork are treated as zero byte file by the Flash Player and cannot be uploaded. (Note: Flash Player 10.1 may resolve this issue)
+ </li>
+ </ul>
+
+</body>
+</html>
View
4 media_tree/static/media_tree/lib/swfupload/plugins/SWFObject License.txt
@@ -0,0 +1,4 @@
+/* SWFObject v2.0 rc4 <http://code.google.com/p/swfobject/>
+ Copyright (c) 2007 Geoff Stearns, Michael Williams, and Bobby van der Sluis
+ This software is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
+*/
View
53 media_tree/static/media_tree/lib/swfupload/plugins/swfupload.cookies.js
@@ -0,0 +1,53 @@
+/*
+ Cookie Plug-in
+
+ This plug in automatically gets all the cookies for this site and adds them to the post_params.
+ Cookies are loaded only on initialization. The refreshCookies function can be called to update the post_params.
+ The cookies will override any other post params with the same name.
+*/
+
+var SWFUpload;
+if (typeof(SWFUpload) === "function") {
+ SWFUpload.prototype.initSettings = function (oldInitSettings) {
+ return function (userSettings) {
+ if (typeof(oldInitSettings) === "function") {
+ oldInitSettings.call(this, userSettings);
+ }
+
+ this.refreshCookies(false); // The false parameter must be sent since SWFUpload has not initialzed at this point
+ };
+ }(SWFUpload.prototype.initSettings);
+
+ // refreshes the post_params and updates SWFUpload. The sendToFlash parameters is optional and defaults to True
+ SWFUpload.prototype.refreshCookies = function (sendToFlash) {
+ if (sendToFlash === undefined) {
+ sendToFlash = true;
+ }
+ sendToFlash = !!sendToFlash;
+
+ // Get the post_params object
+ var postParams = this.settings.post_params;
+
+ // Get the cookies
+ var i, cookieArray = document.cookie.split(';'), caLength = cookieArray.length, c, eqIndex, name, value;
+ for (i = 0; i < caLength; i++) {
+ c = cookieArray[i];
+
+ // Left Trim spaces
+ while (c.charAt(0) === " ") {
+ c = c.substring(1, c.length);
+ }
+ eqIndex = c.indexOf("=");
+ if (eqIndex > 0) {
+ name = c.substring(0, eqIndex);
+ value = c.substring(eqIndex + 1);
+ postParams[name] = value;
+ }
+ }
+
+ if (sendToFlash) {
+ this.setPostParams(postParams);
+ }
+ };
+
+}
View
96 media_tree/static/media_tree/lib/swfupload/plugins/swfupload.proxy.js
@@ -0,0 +1,96 @@
+/*
+ Proxy Plug-in
+
+ Features:
+ Times an upload to see if it appear suspiciously fast which might indicate a proxy server or anti-virus suite intercepting the upload.
+ If the upload seems too fast an uploadError event is fired with PROXY error code after the final uploadProgress event.
+
+ Adds a SWFUpload setting allowing you to tweak the bytes/s for triggering the error:
+ proxy_detect_threshold : 256000
+
+ Adds an UPLOAD_ERROR entry called PROXY:
+ function uploadError(file, errorCode, message) {
+ if (errorCode === SWFUpload.UPLOAD_ERROR.PROXY) {
+ alert("You might have a proxy!");
+ }
+ }
+ */
+
+var SWFUpload;
+if (typeof(SWFUpload) === "function") {
+ SWFUpload.proxyDetect = {};
+ SWFUpload.UPLOAD_ERROR.PROXY = -30300;
+
+ SWFUpload.prototype.initSettings = (function (oldInitSettings) {
+ return function (userSettings) {
+ if (typeof(oldInitSettings) === "function") {
+ oldInitSettings.call(this, userSettings);
+ }
+
+ this.ensureDefault = function (settingName, defaultValue) {
+ this.settings[settingName] = (userSettings[settingName] == undefined) ? defaultValue : userSettings[settingName];
+ };
+
+ // List used to keep the speed stats for the files we are tracking
+ this.proxyDetectFileStartTimes = {};
+ this.proxyDetectSettings = {};
+
+ this.ensureDefault("proxy_detect_threshold", 256000); // Default is 250 KB per second
+
+ this.proxyDetectSettings.user_upload_progress_handler = this.settings.upload_progress_handler;
+ this.proxyDetectSettings.user_upload_complete_handler = this.settings.upload_complete_handler;
+
+ this.settings.upload_progress_handler = SWFUpload.proxyDetect.uploadProgressHandler;
+ this.settings.upload_complete_handler = SWFUpload.proxyDetect.uploadCompleteHandler;
+
+
+ delete this.ensureDefault;
+ };
+ }(SWFUpload.prototype.initSettings));
+
+ SWFUpload.proxyDetect.uploadProgressHandler = function (file, bytesComplete, bytesTotal) {
+ var ex1 = null, time, differenceMS, bps;
+ try {
+ if (typeof this.proxyDetectSettings.user_upload_progress_handler === "function") {
+ this.proxyDetectSettings.user_upload_progress_handler.call(this, file, bytesComplete, bytesTotal);
+ }
+ } catch (ex1) { }
+
+
+ if (bytesComplete === 0) {
+ this.proxyDetectFileStartTimes[file.ID] = new Date();
+
+ } else if (bytesComplete === bytesTotal) {
+ try {
+ // Calculate the Bps and decide if we should trigger the error
+ time = new Date();
+ differenceMS = time.getTime() - this.proxyDetectFileStartTimes[file.ID].getTime();
+
+ if (differenceMS === 0) {
+ differenceMS = 1;
+ }
+
+ bps = bytesTotal / (differenceMS * 1000);
+ if (bps > parseInt(this.settings.proxy_detect_threshold, 10)) {
+ this.queueEvent("upload_error_handler", [file, SWFUpload.UPLOAD_ERROR.PROXY, bps]);
+ }
+ } catch (ex) {
+ }
+ }
+
+ if (ex1 !== null) {
+ throw(ex1);
+ }
+ };
+
+ SWFUpload.proxyDetect.uploadCompleteHandler = function (file) {
+ try {
+ delete this.proxyDetectFileStartTimes[file.ID];
+ } catch (ex) {
+ }
+
+ if (typeof this.proxyDetectSettings.user_upload_progress_handler === "function") {
+ return this.proxyDetectSettings.user_upload_progress_handler.call(this, file);
+ }
+ };
+}
View
98 media_tree/static/media_tree/lib/swfupload/plugins/swfupload.queue.js
@@ -0,0 +1,98 @@
+/*
+ Queue Plug-in
+
+ Features:
+ *Adds a cancelQueue() method for cancelling the entire queue.
+ *All queued files are uploaded when startUpload() is called.
+ *If false is returned from uploadComplete then the queue upload is stopped.
+ If false is not returned (strict comparison) then the queue upload is continued.
+ *Adds a QueueComplete event that is fired when all the queued files have finished uploading.
+ Set the event handler with the queue_complete_handler setting.
+
+ */
+
+var SWFUpload;
+if (typeof(SWFUpload) === "function") {
+ SWFUpload.queue = {};
+
+ SWFUpload.prototype.initSettings = (function (oldInitSettings) {
+ return function (userSettings) {
+ if (typeof(oldInitSettings) === "function") {
+ oldInitSettings.call(this, userSettings);
+ }
+
+ this.queueSettings = {};
+
+ this.queueSettings.queue_cancelled_flag = false;
+ this.queueSettings.queue_upload_count = 0;
+
+ this.queueSettings.user_upload_complete_handler = this.settings.upload_complete_handler;
+ this.queueSettings.user_upload_start_handler = this.settings.upload_start_handler;
+ this.settings.upload_complete_handler = SWFUpload.queue.uploadCompleteHandler;
+ this.settings.upload_start_handler = SWFUpload.queue.uploadStartHandler;
+
+ this.settings.queue_complete_handler = userSettings.queue_complete_handler || null;
+ };
+ })(SWFUpload.prototype.initSettings);
+
+ SWFUpload.prototype.startUpload = function (fileID) {
+ this.queueSettings.queue_cancelled_flag = false;
+ this.callFlash("StartUpload", [fileID]);
+ };
+
+ SWFUpload.prototype.cancelQueue = function () {
+ this.queueSettings.queue_cancelled_flag = true;
+ this.stopUpload();
+
+ var stats = this.getStats();
+ while (stats.files_queued > 0) {
+ this.cancelUpload();
+ stats = this.getStats();
+ }
+ };
+
+ SWFUpload.queue.uploadStartHandler = function (file) {
+ var returnValue;
+ if (typeof(this.queueSettings.user_upload_start_handler) === "function") {
+ returnValue = this.queueSettings.user_upload_start_handler.call(this, file);
+ }
+
+ // To prevent upload a real "FALSE" value must be returned, otherwise default to a real "TRUE" value.
+ returnValue = (returnValue === false) ? false : true;
+
+ this.queueSettings.queue_cancelled_flag = !returnValue;
+
+ return returnValue;
+ };
+
+ SWFUpload.queue.uploadCompleteHandler = function (file) {
+ var user_upload_complete_handler = this.queueSettings.user_upload_complete_handler;
+ var continueUpload;
+
+ if (file.filestatus === SWFUpload.FILE_STATUS.COMPLETE) {
+ this.queueSettings.queue_upload_count++;
+ }
+
+ if (typeof(user_upload_complete_handler) === "function") {
+ continueUpload = (user_upload_complete_handler.call(this, file) === false) ? false : true;
+ } else if (file.filestatus === SWFUpload.FILE_STATUS.QUEUED) {
+ // If the file was stopped and re-queued don't restart the upload
+ continueUpload = false;
+ } else {
+ continueUpload = true;
+ }
+
+ if (continueUpload) {
+ var stats = this.getStats();
+ if (stats.files_queued > 0 && this.queueSettings.queue_cancelled_flag === false) {
+ this.startUpload();
+ } else if (this.queueSettings.queue_cancelled_flag === false) {
+ this.queueEvent("queue_complete_handler", [this.queueSettings.queue_upload_count]);
+ this.queueSettings.queue_upload_count = 0;
+ } else {
+ this.queueSettings.queue_cancelled_flag = false;
+ this.queueSettings.queue_upload_count = 0;
+ }
+ }
+ };
+}
View
346 media_tree/static/media_tree/lib/swfupload/plugins/swfupload.speed.js
@@ -0,0 +1,346 @@
+/*
+ Speed Plug-in
+
+ Features:
+ *Adds several properties to the 'file' object indicated upload speed, time left, upload time, etc.
+ - currentSpeed -- String indicating the upload speed, bits per second
+ - averageSpeed -- Overall average upload speed, bits per second
+ - movingAverageSpeed -- Speed over averaged over the last several measurements, bits per second
+ - timeRemaining -- Estimated remaining upload time in seconds
+ - timeElapsed -- Number of seconds passed for this upload
+ - percentUploaded -- Percentage of the file uploaded (0 to 100)
+ - sizeUploaded -- Formatted size uploaded so far, bytes
+
+ *Adds setting 'moving_average_history_size' for defining the window size used to calculate the moving average speed.
+
+ *Adds several Formatting functions for formatting that values provided on the file object.
+ - SWFUpload.speed.formatBPS(bps) -- outputs string formatted in the best units (Gbps, Mbps, Kbps, bps)
+ - SWFUpload.speed.formatTime(seconds) -- outputs string formatted in the best units (x Hr y M z S)
+ - SWFUpload.speed.formatSize(bytes) -- outputs string formatted in the best units (w GB x MB y KB z B )
+ - SWFUpload.speed.formatPercent(percent) -- outputs string formatted with a percent sign (x.xx %)
+ - SWFUpload.speed.formatUnits(baseNumber, divisionArray, unitLabelArray, fractionalBoolean)
+ - Formats a number using the division array to determine how to apply the labels in the Label Array
+ - factionalBoolean indicates whether the number should be returned as a single fractional number with a unit (speed)
+ or as several numbers labeled with units (time)
+ */
+
+var SWFUpload;
+if (typeof(SWFUpload) === "function") {
+ SWFUpload.speed = {};
+
+ SWFUpload.prototype.initSettings = (function (oldInitSettings) {
+ return function (userSettings) {
+ if (typeof(oldInitSettings) === "function") {
+ oldInitSettings.call(this, userSettings);
+ }
+
+ this.ensureDefault = function (settingName, defaultValue) {
+ this.settings[settingName] = (userSettings[settingName] == undefined) ? defaultValue : userSettings[settingName];
+ };
+
+ // List used to keep the speed stats for the files we are tracking
+ this.fileSpeedStats = {};
+ this.speedSettings = {};
+
+ this.ensureDefault("moving_average_history_size", "10");
+
+ this.speedSettings.user_file_queued_handler = this.settings.file_queued_handler;
+ this.speedSettings.user_file_queue_error_handler = this.settings.file_queue_error_handler;
+ this.speedSettings.user_upload_start_handler = this.settings.upload_start_handler;
+ this.speedSettings.user_upload_error_handler = this.settings.upload_error_handler;
+ this.speedSettings.user_upload_progress_handler = this.settings.upload_progress_handler;
+ this.speedSettings.user_upload_success_handler = this.settings.upload_success_handler;
+ this.speedSettings.user_upload_complete_handler = this.settings.upload_complete_handler;
+
+ this.settings.file_queued_handler = SWFUpload.speed.fileQueuedHandler;
+ this.settings.file_queue_error_handler = SWFUpload.speed.fileQueueErrorHandler;
+ this.settings.upload_start_handler = SWFUpload.speed.uploadStartHandler;
+ this.settings.upload_error_handler = SWFUpload.speed.uploadErrorHandler;
+ this.settings.upload_progress_handler = SWFUpload.speed.uploadProgressHandler;
+ this.settings.upload_success_handler = SWFUpload.speed.uploadSuccessHandler;
+ this.settings.upload_complete_handler = SWFUpload.speed.uploadCompleteHandler;
+
+ delete this.ensureDefault;
+ };
+ })(SWFUpload.prototype.initSettings);
+
+
+ SWFUpload.speed.fileQueuedHandler = function (file) {
+ if (typeof this.speedSettings.user_file_queued_handler === "function") {
+ file = SWFUpload.speed.extendFile(file);
+
+ return this.speedSettings.user_file_queued_handler.call(this, file);
+ }
+ };
+
+ SWFUpload.speed.fileQueueErrorHandler = function (file, errorCode, message) {
+ if (typeof this.speedSettings.user_file_queue_error_handler === "function") {
+ file = SWFUpload.speed.extendFile(file);
+
+ return this.speedSettings.user_file_queue_error_handler.call(this, file, errorCode, message);
+ }
+ };
+
+ SWFUpload.speed.uploadStartHandler = function (file) {
+ if (typeof this.speedSettings.user_upload_start_handler === "function") {
+ file = SWFUpload.speed.extendFile(file, this.fileSpeedStats);
+ return this.speedSettings.user_upload_start_handler.call(this, file);
+ }
+ };
+
+ SWFUpload.speed.uploadErrorHandler = function (file, errorCode, message) {
+ file = SWFUpload.speed.extendFile(file, this.fileSpeedStats);
+ SWFUpload.speed.removeTracking(file, this.fileSpeedStats);
+
+ if (typeof this.speedSettings.user_upload_error_handler === "function") {
+ return this.speedSettings.user_upload_error_handler.call(this, file, errorCode, message);
+ }
+ };
+ SWFUpload.speed.uploadProgressHandler = function (file, bytesComplete, bytesTotal) {
+ this.updateTracking(file, bytesComplete);
+ file = SWFUpload.speed.extendFile(file, this.fileSpeedStats);
+
+ if (typeof this.speedSettings.user_upload_progress_handler === "function") {