Flash: Force Download… No more dirty tricks in Flash 8

September 16th, 2005 by Luis

Following up our post Force Download where we discussed a few tricks to download a picture directly from flash using getURL and a simple php script, I feel like continue the post adding how you can achieve the same or even better by using the FileReference.download method in Flash 8.

Cleaner better and simpler:

  1. import flash.net.FileReference;
  2. var myPic = "url to my picture";
  3. var fileRef:FileReference = new FileReference();
  5. function bringmethePicture(){
  6.     fileRef.download(myPic, 'IMG_0200.jpg')
  7. }

Sample swf: (just right click the picture to download the image): [flash]http://www.blog.lessrain.com/wp-content/upload/download2.swf,350,200[/flash]

36 Responses to “Flash: Force Download… No more dirty tricks in Flash 8”

  1. Gustavo (a.k.a. pcMan) Says:

    Nice thing Luis (y)…… do you remember me, from #FlashPro? … lithien, alesys, fernman, etc? xD saludos amigo ;)

  2. riccardo Says:

    seems not to work with firefox and explorer

  3. Luis Says:

    Ummm.. it works to me in explorer.. I haven’t test it yet in Firefox…

  4. Luis Says:

    It works in firefox 1.0.6 too… do u have the latest release of flash 8 plugin?

  5. ricardo cabello Says:

    FlashPro! such a good days ;) I was there too :D

    The code works fine on opera. Thanks for that!

  6. David R Says:

    In firefox 1.0.6 w/ latest release version of flash plugin…it prompts me to download, and i press Save, but the file never gets downloaded.

  7. vincent Says:

    Does not work with fireFox 1.5 beta 1.

  8. Luis Says:

    Yes u r right doesn’t work … but it works from here:


    Must be a problem with the path and the plugin I’m using to display flash in wordpress.

  9. vincent Says:

    Yes that works, nice one.

  10. tony Says:

    Did anyone ever figure out why files over 20k won’t download, for example the one above doesn’t work for me in any browser, IE, opera, or firefox, any ideas? Is it a secret security issue or something?

  11. Diego Mascarenhas Says:

    I’ll would like to download the script in flash format.


  12. EK Says:

    it’s not working for me either in Safari/Tiger, this would be so great if it would actually work

  13. dude Says:

    Does NOT work in Firefox…

  14. Perm Says:

    So what’s the trick? I’m having the same issues not being able to acutally receive the download. I’m using an XML file which holds the path to the file, which it finds but never gets.

  15. Perm Says:

    Can you use this function on local system files? I am designing an interface right now for company resources, and it doesn’t seem to want to grab the files or establish a “save as” window.

  16. Jasper Says:

    Wow, this is nice. Luis, can you post the fla for this? Thanks so much.

  17. Ben Says:

    Works in FF on MAC/Tiger…AND FF on the PC/XP! I dont know what you guys are talking about…

  18. Aaron Says:

    bump » Did anyone ever figure out why files over 20k won’t download..

    Anyone know about this?
    I am having this problem right now.

    Thank you!

  19. Jenn Says:

    I’m having the same problem with some code I’ve developed. It seems to work when the content of the file is text but not with any other file content types (changing the extensions doesn’t fix it).

    Has anyone come across a solution yet?

  20. rt Says:

    I am working with upload and download(FileReference).Both upload and download works for .txt files but not for other files.The file size is returned as 0 for others.
    Please help!!

  21. hibit Says:

    It doesnt seem to work when downloading a file from a FTP server.
    Does only supports downloads over http?

    Any ideas?

  22. Ben Says:


    it does work for me. Maybe you just think it doesn’t work because no download dialog pops up. At least this is what normally happens. So just check if the file is download you won’t see a classic style download window ;)

  23. artisan Says:

    I need a script or something that would work on a distributable cd-rom… The http thing wont work. Any ideas?

    Thanks in advance.

  24. george margaris Says:

    works fine.

  25. Alfonso Says:

    I created my own flash MP3 downloader and it worked on some computers and not on others? I found out that the security levels were blocking my mp3 files from being downloaded. specifically “Submit nonencrypted form data” should be enabled. anyway I can’t download the above image and I’m using IE 6, but I found a site that might help resolve this issue.
    hopefully this helps everyone!


  26. Aikido Says:

    I was looking for something like this and I didn’r expect to find it that quickly. God bless Google ;) Thanks a lot!

  27. zachary Says:

    I found this solution, and also encountered all the problems of many before me. After some digging I’ve narrowed my problem with the fileReference to two flash 8/9 security changes.

    First off, make sure you have crossdomain access covered.

    Also, if you use a relative file path to the images location it will need to be relative to the actual swfs location, and not the html location the swf is loaded into.

    hope this helps.

  28. timo Says:

    I was having problems with FileReference.download(), but


    had the answer. The instance of FileReference should not go out of scope during the download process. In other words, if you’re working with classes, define the filereference as a class member instead of a local variable in a method. Hope this helps.

    However, I’m still not quite satisfied with the download functionality. Would anyone have an idea if it is possible to use the browser default download agent to handle the download? It would be great if on Firefox for example the usual Downloads window would display the Flash downloads also…

  29. yoyo Says:

    It doesn’t work! :P

  30. yoyo Says:

    http://www.blog.lessrain.com/swfsamples/download2.html it works here XD

  31. matt Says:

    Please can someone post a fla for this? does this code go on a button or a frame - i suspect frame - but if so, how do you reference it from a button?

  32. guy Says:

    Do you have any ideas on how to resize images on the client side prior to uploading? I’ve already worked out an activex control but I am trying to find something compatible w mozilla as well

  33. Michael Johnson Says:

    How can I get this to work in AS3?



  34. Jimmy Says:

    Yes, I need this to work in AS3 also,
    please help,


  35. Serg Says:

    Hello everyone,

    May be you would be interested to look at another flash upload utility:
    http://www.easyalgo.com/eaflashupload.aspx. It has three different user interfaces and many advanced features such as: send variables as form fields values, retrive browser cookie, assign description for each file, JavaScript API, compatibility with Flash Player 10 security restrictions.

  36. iamnotbored.com » Blog Archive » flash actionscript force download Says:

    […] ?> http://www.blog.lessrain.com/flash-force-download-no-more-dirty-tricks-in-flash-8/ […]

Leave a Reply