Page 1 of 1

save to server

Posted: Tue Jun 23, 2009 9:07 pm
by ootweb
PHP Newbie here,
I have a flex app that iam using alivepdf to create a pdf document the current code below allows the user to download the pdf file, i would also like to upload the same pdf to the server is this possible?
any help would be appreciated or point me in the right direction

Cheers
B

Code: Select all

<?php
 
$method = $_GET['method'];
$name = $_GET['name'];
 
if ( isset ( $GLOBALS["HTTP_RAW_POST_DATA"] )) {
    
    // get bytearray
    $pdf = $GLOBALS["HTTP_RAW_POST_DATA"];
    
    // 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 'An error occured.';
 
?>

Re: save to server

Posted: Thu Jul 23, 2009 11:03 pm
by ootweb
Hi guys,

still downloads to users computer but doesnt upload to the server

Code: Select all

<?php
 
$method = $_GET['method'];
$name = $_GET['name'];
$path = "save/";
 
if ( isset ( $GLOBALS["HTTP_RAW_POST_DATA"] )) {
    
    $handle = fopen($Path, "w");
    fwrite($handle, $pdf);
    fclose($handle);
 
    // get bytearray
    $pdf = $GLOBALS["HTTP_RAW_POST_DATA"];
    
    // 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 'An error occured.';
 
?>