Flash: Force Download… No more dirty tricks in Flash 8
September 16th, 2005 by LuisFollowing 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:
Actionscript:
- import flash.net.FileReference;
- var myPic = "url to my picture";
- var fileRef:FileReference = new FileReference();
- function bringmethePicture(){
- fileRef.download(myPic, 'IMG_0200.jpg')
- }
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]


September 16th, 2005 at 1:20 pm
Nice thing Luis (y)…… do you remember me, from #FlashPro? … lithien, alesys, fernman, etc? xD saludos amigo
September 16th, 2005 at 2:10 pm
seems not to work with firefox and explorer
September 16th, 2005 at 2:12 pm
Ummm.. it works to me in explorer.. I haven’t test it yet in Firefox…
September 16th, 2005 at 2:14 pm
It works in firefox 1.0.6 too… do u have the latest release of flash 8 plugin?
September 16th, 2005 at 3:28 pm
FlashPro! such a good days
I was there too
The code works fine on opera. Thanks for that!
September 16th, 2005 at 8:54 pm
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.
September 16th, 2005 at 9:01 pm
Does not work with fireFox 1.5 beta 1.
September 17th, 2005 at 11:24 am
Yes u r right doesn’t work … but it works from here:
http://www.blog.lessrain.com/swfsamples/download2.html
Must be a problem with the path and the plugin I’m using to display flash in wordpress.
September 17th, 2005 at 2:31 pm
Yes that works, nice one.
November 14th, 2005 at 9:40 pm
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?
December 15th, 2005 at 5:19 pm
I’ll would like to download the script in flash format.
thx.
December 31st, 2005 at 4:25 am
it’s not working for me either in Safari/Tiger, this would be so great if it would actually work
January 5th, 2006 at 6:04 pm
Does NOT work in Firefox…
January 19th, 2006 at 6:11 pm
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.
January 19th, 2006 at 9:56 pm
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.
February 28th, 2006 at 12:55 pm
Wow, this is nice. Luis, can you post the fla for this? Thanks so much.
March 17th, 2006 at 6:55 pm
Works in FF on MAC/Tiger…AND FF on the PC/XP! I dont know what you guys are talking about…
March 22nd, 2006 at 1:16 am
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!
Aaron
May 3rd, 2006 at 1:16 am
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?
July 18th, 2006 at 9:29 pm
Hi,
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!!
July 31st, 2006 at 12:25 pm
It doesnt seem to work when downloading a file from a FTP server.
Does only supports downloads over http?
Any ideas?
September 8th, 2006 at 2:20 pm
Hi,
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
September 22nd, 2006 at 6:49 pm
I need a script or something that would work on a distributable cd-rom… The http thing wont work. Any ideas?
Thanks in advance.
February 12th, 2007 at 4:21 am
works fine.
February 17th, 2007 at 12:36 am
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!
http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=3637d5c3
February 21st, 2007 at 10:17 am
I was looking for something like this and I didn’r expect to find it that quickly. God bless Google
Thanks a lot!
June 19th, 2007 at 11:26 pm
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.
http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_14213&sliceId=1
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.
z
September 7th, 2007 at 9:11 am
I was having problems with FileReference.download(), but
http://livedocs.adobe.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00002210.html
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…
October 5th, 2007 at 8:17 pm
It doesn’t work!
October 5th, 2007 at 8:25 pm
http://www.blog.lessrain.com/swfsamples/download2.html it works here XD
October 18th, 2007 at 9:22 pm
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?
October 26th, 2007 at 10:00 am
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
April 4th, 2008 at 8:47 am
How can I get this to work in AS3?
Truly,
m
May 12th, 2008 at 5:01 pm
Yes, I need this to work in AS3 also,
please help,
Thanks!
March 17th, 2009 at 11:52 am
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.
April 14th, 2009 at 12:37 am
[…] ?> http://www.blog.lessrain.com/flash-force-download-no-more-dirty-tricks-in-flash-8/ […]