save to server

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ootweb
Forum Newbie
Posts: 2
Joined: Tue Jun 23, 2009 9:02 pm

save to server

Post 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.';
 
?>
Last edited by Benjamin on Tue Jun 23, 2009 11:36 pm, edited 1 time in total.
Reason: Changed code type from text to php.
ootweb
Forum Newbie
Posts: 2
Joined: Tue Jun 23, 2009 9:02 pm

Re: save to server

Post 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.';
 
?>
Post Reply