ootweb Posted July 12, 2009 Share Posted July 12, 2009 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? Cheers B 1.<?php 2. 3.$method = $_GET['method']; 4.$name = $_GET['name']; 5. 6.if ( isset ( $GLOBALS["HTTP_RAW_POST_DATA"] )) { 7. 8. // get bytearray 9. $pdf = $GLOBALS["HTTP_RAW_POST_DATA"]; 10. 11. // add headers for download dialog-box 12. header('Content-Type: application/pdf'); 13. header('Content-Length: '.strlen($pdf)); 14. header('Content-disposition:'.$method.'; filename="'.$name.'"'); 15. echo $pdf; 16. 17.} else echo 'An error occured.'; 18. 19.?> Link to comment https://forums.phpfreaks.com/topic/165733-save-pdf-to-server/ Share on other sites More sharing options...
Guillaume Cantin Posted July 14, 2009 Share Posted July 14, 2009 Hi there, the answer to your question is quite simple, since you've already got it half figured out First, you need to create a $Path Variable containing the path to your save location on your server to execute the code I'm about to show you. The code that you have only makes it available for download by showing it in a pdf page. <?php $handle = fopen($Path, "w"); fwrite($handle, $pdf); fclose($handle); ?> You should add these 3 lines (without the <?php and ?> brackets) before line 11 of your program, and everything should go fine if you've set your $Path variable correctly. Took me a while to figure out too Link to comment https://forums.phpfreaks.com/topic/165733-save-pdf-to-server/#findComment-875155 Share on other sites More sharing options...
ootweb Posted July 15, 2009 Author Share Posted July 15, 2009 thanks for the reply the .php file was taken from the alivepdf sample so i did not write it this does not work? <?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.'; ?> ] Link to comment https://forums.phpfreaks.com/topic/165733-save-pdf-to-server/#findComment-875511 Share on other sites More sharing options...
Guillaume Cantin Posted July 17, 2009 Share Posted July 17, 2009 What is it that does not work? The saving of the pdf, the output, or something else, please be more specific Link to comment https://forums.phpfreaks.com/topic/165733-save-pdf-to-server/#findComment-877042 Share on other sites More sharing options...
ootweb Posted July 19, 2009 Author Share Posted July 19, 2009 sorry for not being more specific, the pdf does not save to the server, it downloads to the users computer without a problem regards b Link to comment https://forums.phpfreaks.com/topic/165733-save-pdf-to-server/#findComment-878310 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.