FileReference updated in Macromedia Flash Player 9 beta 3

flash.net.FileReference class, in latest beta of Macromedia Flash Player 9, has been updated. Let’s see the FileReference.upload(..) method signature.

public function upload(request:URLRequest,
uploadDataFieldName:String = "Filedata", testUpload:Boolean = false):void

Following are things, I noticed in the latest beta.

  • Custom data-field name, which was hard-coded(as FileData) in previous version of player. Now you can change it by using uploadDataFieldName parameter of upload method of FileReference.
  • You can now send HTTP/POST parameters with file-upload request. Previous version of player only allowed you to send HTTP/GET parameters. You can use first parameter request to send HTTP POST or GET parameters.

This means, I can now go ahead and complete my Flickr AS3 API. I was stuck, when I wanted to upload pictures to Flickr. Darron’s Flickr AS3 library was also missing file-upload feature because of above mentioned limitation in previous versions of Flash Player 9 beta. I am sure, Darron must have updated Flickr AS3 library.

  • Rama

    Hi Abdul,
    I am trying to use the FileReference Class to load images into my flex application directly at runtime….however i cannot trace the complete location of the file i select from the browse method…..can u help??
    send me some link or anything!,
    Rama.
    Thanks in advance

  • Rajesh Bhadra

    hi, can you tell me how to upload an image on the swf file in Flex(Flex 2 beta 3) using FileReference and send it across to the coldfusion and store it in some file system….thank you

  • Hi Rama,
    Due to security sandbox, you can not get the complete path of local-file. You would only get the filename. I understand, it’s frustrating but at the same time secuirty is also important.
    You have to do roundtrip (upload to server then download from server) to make it work..
    -abdul

  • Hi Rajesh,
    You can look at Flex 2.0 live docs, there are many examples.
    http://livedocs.macromedia.com/labs/1/flex/langref/flash/net/FileReferenceList.html
    If you still have problem, let me know.
    For coldfusion, I think, following code should work.
    <cfset destinationPath = “uploads\”/>
    <cffile action=”upload” fileField=”Filedata” destination=”#destinationPath#” nameConflict=”makeUnique” />

  • Hi Abdul.
    Can you upload photos to flickr?
    I try to update the code of Darron’s Flickr Api, but I can’t sent photos…
    Can you send me your modifications of Photos.upload? Only if you worked on it, of course.
    Thanks!!

  • the latest beta’s features are really cool, it’s more advanced than the previous version, especially “You can now send HTTP/POST parameters with file-upload request”

  • Hello,
    Im searching for code to loging in to flickr and upload pictures with flash as.
    Can someone tell me if there is an example script to find somewhere, I know the basics of actionscript,Im not advanced yet.
    Hope that you can help,greetings,Ber.

  • sandhya

    hi adbul,
    i m trying to use richtexteditor in coldfusion mxml files. But I am not able to do it. can you please helkp me with this

  • Hi Abdul,
    Why do I keep getting error messages from my Abdul Flash Player?
    It keeps saying it wants to access web content on my PC.
    My Abdul Acrobat Reader is fine…

  • Naveen

    you can use the file reference to find the absolute path by using the load() function .. but the only way you can do that is by updating your flash player to version 10.0.0 or more and you need to download the latest nightly version of gombo sdk ..
    http://opensource.adobe.com/wiki/display/flexsdk/Download+Flex+4/
    The steps to install the sdk is as follows..
    1. download from the link given above
    2. extract it and paste it under ur c:/… flexBuilder3/sdk/
    3. create a new project in ur builder and then gotto project > properties
    4. under Flex Compiler click Configure Flex SDKs .. and then add the location of your flex sdk and click ok
    5. then change the specifc SDK to Flex4.0….. version
    6. under Require Flsh Player version .. chnage it to 10.0.0 and click ok
    This should help you use filereference.load() and fileReference.data
    call the event
    fileReference.addEventListener(Event.SELECT, onSelectFile);
    fileReference.addEventListener(Event.COMPLETE, fileReference_complete);
    private function onSelectFile(event:Event):void{
    fileReference.load();
    }
    private function fileReference_complete(evt:Event):void {
    img.source = fileReference.data;
    }
    This should work !
    -Naveen !