[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 436
  • Last Modified:

Browse and download files from server using Flash AS3 and PHP

How can I browse and download files from a server in flash using actionscript 3 and php?
0
Lunar76
Asked:
Lunar76
  • 4
  • 2
1 Solution
 
CSecurityCommented:
In PHP you should write code to send files to visitor, like

download.php?filename=[FILENAME]

and in code inside write a code which reads file content and prints it out, like filecontent function

In ActionScript 3 make an HTTP request to PHP and get it's output.

0
 
Lunar76Author Commented:
Thanks CSecurity, but can you show me some as3 and php code, that does this exactly?
0
 
CSecurityCommented:
It's the PHP part
<?

if (isset($_GET['filename'])) 
{

$file= $_GET['filename'];
if (file_exists($file))
{
           header("Pragma: public");
           header('Expires: '.gmdate('D, d M Y H:i:s').' GMT');
           header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
           header("Cache-Control: private",false);
           header("Content-Type: application/x-msdownload");
           header('Content-Disposition: attachment; filename="file.exe"');
           header("Content-Transfer-Encoding: binary");
           header('Content-Length: '.filesize($file));
           @set_time_limit(0);
           @readfile($file);
           exit;
}
}




?>

Open in new window

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
CSecurityCommented:
you can call this PHP file download.php

Then you can call it like:

download.php?filename=test.txt

test.txt could any name which exists in server.
0
 
CSecurityCommented:
And see this:

http://snipplr.com/view/5124/as3-sending-and-recieving-data-using-a-get-request/

It's AS3 makes HTTP request and receives response
0
 
Lunar76Author Commented:
Answer is too vague
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now