AS3 FileReference Example

AS3 FileReference Pic

A while ago I made a post about FileReference in AS2. For a recent project I needed to create a simple uploader class which uploads files to a given server from flash, so once again I was face to face with FileReference, but this time in AS3. The syntax is almost identical, with a few small nuances. Ill let you download the source** to get the full details.

This example has some a few small frills, my favorite of which is the constructor takes a directory name where you would like the file to be uploaded (relative to the upload script), this allows me to reuse this class for many different uploads, to different directories.

** Note: For this to work you need to put “upload.php” on your server and point the variable ‘phpUploadScript’ in FileUploader.as on line 20 to upload.php.