javascript - Automatic "download" PDF as upon form submission -


i have form button, when clicked submits form.

i'd @ same time, browser starts downloading pdf file. wonder how can this? please keep in mind pdf opened browser default, i'd browser "save as" file , not open file. do-able using html or need javascript?

if using php in server side try this. tested code running in 1 of websites.

<?php     ob_start();     $file = 'your-filename-here.pdf';      if (file_exists($file))      {         header('content-description: file transfer');         header('content-type: application/octet-stream');         header('content-disposition: attachment; filename='.basename($file));         header('content-transfer-encoding: binary');         header('expires: 0');         header('cache-control: must-revalidate');         header('pragma: public');         header('content-length: ' . filesize($file));         ob_clean();         flush();         readfile($file);         exit();     } ?> 

browser prompt download without displaying in browser.


Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -