PDA

View Full Version : File Downloads..


motome
11-05-2008, 04:56 PM
ok I am sure this has been asked alot, but the serch function is not being kind.. so.. here it goes. I created an app to help not so computer savvy users download a file. I would like to do 2 things with it.

1. Make it so it doesnt open a new webpage, and show the link to the file.

2. Somehow write it so we can put it on our FTP server and have the app log into and Download the file fromt he FTP rather than putting it on our http server. If it helps here is my current working code.

stop();

var _fileName:String = "this is stupid";
var _passwordField:String;
var _passwordHolder:String = "mypassword";

download_btn.addEventListener(MouseEvent.CLICK, getFileName);
download_btn.addEventListener(MouseEvent.CLICK, downloadFile);
download_btn.addEventListener(MouseEvent.CLICK, downloadTheFile);

function getFileName(event:MouseEvent):void {
_fileName = fileName_txt.text;
_passwordField = password_txt.text;
}
function downloadFile(event:MouseEvent):void {
//getUrl("your.pdf","_blank", "GET");
trace(_fileName);
trace(_passwordField);
}

function downloadTheFile(event:MouseEvent):void {
if (_passwordHolder == _passwordField) {
var downloadFileURL:URLRequest = new URLRequest("http://video.sonew.tv/ftpcheat/" + _fileName);
navigateToURL(downloadFileURL);
} else {
gotoAndPlay(2);
}
}

Rossman
11-05-2008, 06:51 PM
You'll want to be using the FileReference.download() method, not navigateToURL.

Cheers,
mark

motome
11-05-2008, 08:58 PM
Thank you.. switched to that, and it allowed me to work it. Plus allowed me to use event.bytesLoaded. Now all I need to figure out is how to get the file from an FTP server. However from my research it looks like I may need PHP to do that, and that may be a bit beyond me.

Rossman
11-05-2008, 09:24 PM
Yeah, for FTPing you will probably need to use PHP or something similar.