YUI Uploader provides file upload functionality that goes beyond the basic browser-based methods. Specifically, the YUI Uploader allows for:
Important usage notes:
To use the Uploader Control, include the following source files in your web page:
Instead of copying and pasting the filepaths above, try letting the YUI dependency Configurator determine the optimal file list for your desired components; the Configurator uses YUI Loader write out the full HTML for including the precise files you need for your implementation.
Note: If you wish to include this component via the YUI Loader, its module name is uploader. (Click here for the full list of module names for YUI Loader.)
Where these files come from: The files included using the text above will be served from Yahoo! servers; see "Serving YUI Files from Yahoo!" for important information about this service. JavaScript files are minified, meaning that comments and white space have been removed to make them more efficient to download. To use the full, commented versions or the -debug versions of YUI JavaScript files, please download the library distribution and host the files on your own server.
Order matters: As is the case generally with JavaScript and CSS, order matters; these files should be included in the order specified above. If you include files in the wrong order, errors may result.
By default, the file uploader.swf is expected in the assets directory relative to the location of the HTML page in which a Uploader Control instance will appear. If you wish use uploader.swf from yui.yahooapis.com, or if you'd like to place uploader.swf in a different location on your own server, you may specify a path (relative to the page or absolute) by setting the following variable:
To get started with the Uploader Control, begin by placing it on the page. Create a <div> (or other element) placeholder into which you'l render your Uploader instance. In a typical usage scenario, you can set the width and height of the container to 0, since the Uploader is a purely functional component and does not have UI of its own (although it does display status messages that can be useful for debugging):
Finally, instantiate the Uploader by passing the id of the container <div> to it:
The Uploader has a number of methods that allow the developer to invoke the "Open File" dialog and manage the file queuing and upload process. The Uploader also dispatches various events for different aspects of the upload process.
In order to receive events from the Uploader, you need to add event listeners. For example, to add a listener for a fileSelect event, do the following:
This means that when the user selects the files using the "Open File" dialog, the onFileSelectfunction will be called and an event object will be passed to it. The following events are dispatched by the Uploader:
The Uploader Control supports the following methods:
There are many ways of handling the request on the server. The following example uses PHP to write submissions from an HTTP GET request to the same directory as the directory the script lives in. Note that this requires write permissions to the directory the script lives in. Always consider security implications when setting such permissions.
uploader.swf file. If uploader.swf hosted by yui.yahooapis.com is used, then the server must contain a cross-domain permissions file allowing yui.yahooapis.com to upload files. By default, Uploader looks for uploader.swf in the assets directory in the same path as uploader.js, so if you’re loading Uploader from yui.yahooapis.com you will be affected by this issue.document.cookie to the upload request.For further exploration of the uploader components, take a look at its example files. Note that in order to run these examples, you will need to copy them to your own web space and have a server capable of accepting uploads.
The YUI Library and related topics are discussed on the on the ydn-javascript mailing list.
In addition, please visit the YUIBlog for updates and articles about the YUI Library written by the library's developers.
The YUI Library's public bug tracking and feature request repositories are located on the YUI SourceForge project site. Before filing new feature requests or bug reports, please review our reporting guidelines.














Copyright © 2008 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Copyright Policy - Job Openings