AlivePDF download and save to server

Today I found myself needing to implement AlivePDF into a project that needs to generate a PDF, save it on the server and download it to the user’s computer.

Since I didn’t find any information about how to do this (and I found some other people trying to find out how it’s done) I thought I should give it a try. I posted the final result below if someone else needs to know how to both save the PDF file on the server and download it to the user’s computer.

ActionScript 3 AlivePDF code:

_pdf.save(Method.REMOTE, "save.php", Download.ATTACHMENT, "MyFile.pdf");

PHP code that will save the file on the server (inside a specified folder) and save it to the user’s computer too:

<?php
 
if(isset($GLOBALS["HTTP_RAW_POST_DATA"])){
	$pdf = $GLOBALS["HTTP_RAW_POST_DATA"];
	$name = $_GET["name"];
	$save_to = "pdf/". $name;
	file_put_contents($save_to, $pdf);
 
	// add headers for download dialog-box
	header('Content-Type: application/pdf');
	header('Content-Length: '.strlen($pdf));
	header('Content-disposition:'.$method.'; filename="'.$name.'"');
	echo $pdf;
 
} else{
	echo "Encoded PDF information not received.";
}
?>
Password protected content in Flash with ActionScript 3 and PHP

This morning I was browsing through the gotoAndLearn forum and I saw a question about how to make a password protected section in a Flash site. So, I made a quick example and I thought I should share it with all my readers too 😉

Read more
Flash contact form

You know those flash contact forms?
I sow a lot of people who don’t know how to make one…
For those who don’t know how to make it… here you can see how it’s done… (inspired from gotoandlearn.com)
You can use that on any of your projects 😉