Monday, February 28, 2011

Downloading file to local disk from server.

This method is quite simple to download any file from server.
navigateToURL(new URLRequest("http://www.mysite/FileGodown/abc.zip"));
or
navigateToURL(new URLRequest("http://www.mysite/FileGodown/abc.jpg"));
/*Browser will ask you for save or open file.*/

Another method is
var _file:FileReference=new FileReference();
 _file.addEventListener(Event.COMPLETE, ImageDownloading);
_file.addEventListener(IOErrorEvent.IO_ERROR, FileIOErrorHandler);
var request:URLRequest = new URLRequest(“http://www.mysite/FileGodown/abc.jpg”);
_file.download(request,fileName)
}

function ImageDownloading(e:Event):void
{
trace(“File downloaded.”)
}
/*Here you will get proper save window to save file. */

You can see this article in FFD Magazine March issue.

No comments:

Post a Comment