FileReference - Upload files with Flash 8

Posted Saturday, August 20, 2005 10:06 AM by Shunjie
Flash 8 brings us 2 new classes which allow us to download or upload file/s directly to the server. FileReference, and the FileReferenceList class, with the latter allowing the upload of multiple files.

FileReference expose several events including onCancel, onComplete, onSecurityError,etc, which allow developer to react to different situation according to the user interaction and Security issues. For example in the past, we download files from the server by calling the getURL method. Since we already got the getURL method, why do we need to use FileReference class to download a file? The answer is that with FileReference class, we can track the download. We can now listen to the onProgress event to track the upload or download progress. Thus, this gives us more control over the operations.

I will not go through the codes here since its available under Flash 8 Help, but its easy to think of facinating things developers can do with it.

Photo sharing service with Flash interface easily can be accompolished since we can now upload / download files directly. Flash 8 also support dynamically loading of gif and png file now, as compared to only jpg files in the past. One thing to note is that once we call the upload() method in either classes, it does not upload directly to a folder we specified, but it will call a remote upload script. How to implement the upload script is up to individual developers. For example, developers can append parameters to the back of the url and get the query strings to differentiate different users. They could then get the post data for the posted files and saved them. I believe we will be able to find a lot of sample scripts for cf, .net , php, etc over time, so flash developers unfamiliar with that need not to worry.

I hope I be will able create a simple photos sharing application using Flash 8 and .NET (with Paladin of course) soon.


Filed under: , ,