|
|
Question : Trigger PDF Download in Flash
|
|
I would like to click a button in Flash and have it trigger a PDF download. I do not want the file to open in a new browser window, and do not want to have to zip the files. Is there any way to do this?
|
Answer : Trigger PDF Download in Flash
|
|
The only way to achieve this is by using server side script like php or php and change the mime type of your pdf to: "application/octet-stream"
in ASP:
<% Response.ContentType = "application/octet-stream" FPath = server.mappath("pathtoyourpdf/file.pdf") Response.AddHeader "Content-Disposition","attachment; filename=" & FPath Set adoStream = CreateObject("ADODB.Stream") adoStream.Open() adoStream.Type = 1 adoStream.LoadFromFile(FPath) Response.BinaryWrite adoStream.Read() adoStream.Close Set adoStream = Nothing Response.End %>
in PHP:
$file = 'file.pdf'; _Download("pathtopdf/".$file, $file);
function _Download($f_location,$f_name){ header ("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Length: ' . filesize($f_location)); header('Content-Disposition: attachment; filename=' . basename($f_name)); readfile($f_location); }
?>
in Flash:
getURL("getPDF.php");
Cheers
Vic
|
|
|
|
|