php - Continue execution after sending file to client -
i'm creating dynamically pdf file , sending client:
private function createpdf($foo) { //delete pdf file if exists if(file_exists('path_to_directory' . $foo->getid() . '.pdf')) unlink('path_to_directory' . $foo->getid() . '.pdf'); //create new pdf file $this->get('knp_snappy.pdf')->generatefromhtml( $this->renderview( 'acmefoobundle:default:pdftemplate.html.twig', array( 'foo' => $foo) ), 'path_to_directory' . $foo->getid() . '.pdf' ); // open file in binary mode $fp = fopen('path_to_directory' . $foo->getid() . '.pdf', 'rb'); header("content-type: application/pdf"); header('content-disposition: attachment; filename="foo.pdf"'); // dump image , stop script fpassthru($fp); exit; }
this function works right, i'd want go on execution after sending file client render "success" template , send client. i've tried things removing exit;
, this: continue execution after calling php passthru() function, no success. idea?
achieved adding javascript event file generation button:
pure js:
<script> window.onload = function() { function redirecttomeeting() { window.settimeout(function() { window.location.href="url_to_go"; }, 2000); } if(document.getelementsbyclassname('create-file-button')) { document.getelementsbyclassname('create-file-button')[0].addeventlistener('click', redirecttomeeting); } }; </script>
then, when button clicked, new file created , sent client, , (after 2 seconds) client redirected url_to_go
.
jquery:
$(function(){ $('#create-file-button').submit(function(ev) { $("#continue").show(); }); });
when form submitted, new button (#continue
) shown lets user go next page (url_to_go
).
php symfony2
No comments:
Post a Comment