Downloading Files with Flex
Posted by: Kenneth in Flex, tags: downloadfile, filereference, FlexJust in case someone faced the same problem i did. Here’s the actual code to download a file with Flex
var fileToDownload:FileReference = new FileReference();
private function downloadFile(event:MouseEvent):void
{
var request:URLRequest = new URLRequest("file.txt");
fileToDownload.download(request, "aSpecificFilenameChosenByYou.txt");
}
It doesn’t work if your file reference object is declared as a local variable. For the non-coders, here is the negative example.
private function downloadFile(event:MouseEvent):void
{
var request:URLRequest = new URLRequest("file.txt");
var fileToDownload:FileReference = new FileReference();
fileToDownload.download(request, "aSpecificFilenameChosenByYou.txt");
}
Entries (RSS)