Flex : save a resource from url to hard drive?
How do I save a resource like "someth开发者_开发技巧ing.rar" from the web, like when it is located on a regular web page?
use FileReference.download(). There is a complete example shown at the adobe doc page.
Here's the basic idea:
var downloadURL:URLRequest = new URLRequest("http://www.[yourDomain].com/SomeFile.pdf");
var file:FileReference = new FileReference();
// add listeners to `file` to catch errors, handle progress, etc
// (see adobe docs for a complete example of the possible listeners)
file.download(downloadURL, fileName);
You're looking for the FileReference class. Here's a tutorial.
精彩评论