Butterbean Posted January 15, 2015 Share Posted January 15, 2015 (edited) I have a button that brings up my systems printer.... <button onClick="window.print()">Print this page</button> I'm trying to find a way to do the same thing but giving me the ability to save-as to my CPU. What would be nice is if I could have separate buttons to save-as a PDF and one for CSV. Each would automatically save to a file, with a comfirmation that its saved. The location would be coded in PHP for the desired format, and all the user has to do is click the button and it is placed in the appropriate folded. is this possible and easy to do across ie, firefox and chrome? Thanks for any direction. . Edited January 15, 2015 by Butterbean Quote Link to comment https://forums.phpfreaks.com/topic/293932-save-as-button/ Share on other sites More sharing options...
Butterbean Posted January 15, 2015 Author Share Posted January 15, 2015 Somebody? Anybody? Hello ello o oo o o oo o oo o o [echoes] Quote Link to comment https://forums.phpfreaks.com/topic/293932-save-as-button/#findComment-1503059 Share on other sites More sharing options...
CroNiX Posted January 15, 2015 Share Posted January 15, 2015 Are these PDF and CSV files something that already exist on the server, or would they have to be created on the fly when someone presses one of the buttons? If they're already existing, just provide links and style them to look like a button or whatever you want: <a href="/path/to/the/file.pdf">PDF</a> If they don't exist, its a bit more complex as the link would be going to a php page or something, which generates the PDF and then sends it to the browser. Quote Link to comment https://forums.phpfreaks.com/topic/293932-save-as-button/#findComment-1503063 Share on other sites More sharing options...
Butterbean Posted January 16, 2015 Author Share Posted January 16, 2015 They would have to be created on the fly. The page where I'm including the buttons is in html. The one I'm mostly concerned with is the CSV file. I need to find a way where every time an html invoice is created, a NACHA certified file is created as a CSV file, then emailed to the customer. I think I can get started on this but its gonna be rocky. Quote Link to comment https://forums.phpfreaks.com/topic/293932-save-as-button/#findComment-1503103 Share on other sites More sharing options...
cyberRobot Posted January 16, 2015 Share Posted January 16, 2015 (edited) The header() function in PHP can be used to force the save-as box to appear. Some examples can be found here: http://php.net/manual/en/function.header.php#refsect1-function.header-examples And here: http://php.net/manual/en/function.readfile.php Edited January 16, 2015 by cyberRobot Quote Link to comment https://forums.phpfreaks.com/topic/293932-save-as-button/#findComment-1503144 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.