PDA

View Full Version : File upload/download problem


nhPaul
09-25-2007, 01:55 AM
Hi,

I can upload files from Flex via PHP, rename them and save the file outside the web root. A MySQL database holds the file information. This works fine. But I'm lost when trying to download the file with Flex and PHP. I can download when in a browser using PHP's readfile() but how do I integrate this with Flex's FileReference's download function? Any help appreciated.

Thanks,

Paul

drkstr
09-25-2007, 05:57 AM
Do you mean save the file to the local file system? That's a no go my friend. If, however, you are talking about downloading an XML file to be used in the application, you can use the URLLoader class.

For local shell and file system access, you will need to use the Adobe AIR runtime.

Best regards,
...aaron

**edit**
Of course you can always use a standard link to download a file w/ the browser. Just use the function

navigateToURL('http://localhost/a_nasty_virus.exe');

*edit again**
I take that back, there is a cleaner way to download files w/ the browser:


var request:URLRequest = new URLRequest("a_nasty_virus.exe");
var fileToDownload:FileReference = new FileReference();
fileToDownload.download(request, "default_virus.exe");