Basics:
1. SWFUpload is a JavaScript library (that requires Flash Player)
2. You initialize SWFUpload using JavaScript (often in the window.onload event). You activate SWFUpload using JavaScript (usually in a buttons onlick event). You monitor and respond to SWFUpload by hooking JavaScript functions to SWFUpload's events.
3. There are some Flash Player bugs that you have to work around in most cases. These are outlined in the documentation and sample code to do this is provided in the package.
Wiring it up
1. Page Loads with the swfupload.js file
2. You create event handler functions. In the demos there are contained in the handler.js file. Your handlers will be unique for your application. You may or may not be able to copy/paste the demo handlers.
3. You initialize SWFupload (usually in the window.onload event) by calling something like 'new SWFUpload();' You need to provide a settings object to the SWFUpload constructor. Each setting is detailed in the documentation.
4. You hook a call to your swfupload object calling 'selectFiles()' to allow the user to get the file selection dialog.
5. You hook a call to your swfupload object calling 'startUpload()' to start uploading the selected files.
6. SWFUpload calls the event handlers you've wired up (in the settings object) and your JavaScript code updates your page dynamically providing progress, success, or error feedback.
Event Flow:
1. fileDialogStart -- called immediately before the file dialog window is opened.
2. fileQueued -- called when each selected file is added to the upload queue.
3. fileQueueError -- called with an error code if a selected file cannot be queued for some reason (file too big, already uploaded too many files, etc).
4. fileDialogComplete -- called after all the selected files have been processed. This is a good place to call startUpload if you want to immediately start the upload once the files are selected.
5. uploadStart -- called after you call startUpload() but before the file actually starts uploading. You can attach form values to the upload or validate something or whatever. Returning 'false' stops and requeues the upload.
6. uploadProgress -- called once in awhile as the file uploads. It will always be called at least once (in later versions of SWFUpload).
7. uploadError -- called if an error occurs or your stop or cancel an upload. An error code is sent which you can handle. No data from the server is available (sorry, it's Flash's fault).
7. uploadSuccess -- called when the webserver returns an HTTP Status Code of 200. You MUST return some text data or uploadSuccess will never fire and you be "stuck" (you can thank Flash for this too). The data you return is passed as a parameter to this event.
8. uploadComplete -- the upload has been complete and SWFUpload is ready to start another upload. You can call startUpload here if you want the next file to start uploading automatically. This is _not_ called when you cancel a file that is not currently uploading (but is called after every other upload is complete or errored or cancelled or stopped).
SWFUpload quick overview
Basics:
1. SWFUpload is a JavaScript library (that requires Flash Player)
2. You initialize SWFUpload using JavaScript (often in the window.onload event). You activate SWFUpload using JavaScript (usually in a buttons onlick event). You monitor and respond to SWFUpload by hooking JavaScript functions to SWFUpload's events.
3. There are some Flash Player bugs that you have to work around in most cases. These are outlined in the documentation and sample code to do this is provided in the package.
Wiring it up
1. Page Loads with the swfupload.js file
2. You create event handler functions. In the demos there are contained in the handler.js file. Your handlers will be unique for your application. You may or may not be able to copy/paste the demo handlers.
3. You initialize SWFupload (usually in the window.onload event) by calling something like 'new SWFUpload();' You need to provide a settings object to the SWFUpload constructor. Each setting is detailed in the documentation.
4. You hook a call to your swfupload object calling 'selectFiles()' to allow the user to get the file selection dialog.
5. You hook a call to your swfupload object calling 'startUpload()' to start uploading the selected files.
6. SWFUpload calls the event handlers you've wired up (in the settings object) and your JavaScript code updates your page dynamically providing progress, success, or error feedback.
Event Flow:
1. fileDialogStart -- called immediately before the file dialog window is opened.
2. fileQueued -- called when each selected file is added to the upload queue.
3. fileQueueError -- called with an error code if a selected file cannot be queued for some reason (file too big, already uploaded too many files, etc).
4. fileDialogComplete -- called after all the selected files have been processed. This is a good place to call startUpload if you want to immediately start the upload once the files are selected.
5. uploadStart -- called after you call startUpload() but before the file actually starts uploading. You can attach form values to the upload or validate something or whatever. Returning 'false' stops and requeues the upload.
6. uploadProgress -- called once in awhile as the file uploads. It will always be called at least once (in later versions of SWFUpload).
7. uploadError -- called if an error occurs or your stop or cancel an upload. An error code is sent which you can handle. No data from the server is available (sorry, it's Flash's fault).
7. uploadSuccess -- called when the webserver returns an HTTP Status Code of 200. You MUST return some text data or uploadSuccess will never fire and you be "stuck" (you can thank Flash for this too). The data you return is passed as a parameter to this event.
8. uploadComplete -- the upload has been complete and SWFUpload is ready to start another upload. You can call startUpload here if you want the next file to start uploading automatically. This is _not_ called when you cancel a file that is not currently uploading (but is called after every other upload is complete or errored or cancelled or stopped).