I usually go to a web site every day and open their daily different PDF and then click on the PDF diskette icon and save it locally to my computer hard disk.
What I need is a script to save it not to my local hard disk but to my server and automatically. Essentially: move a PDF whose daily address on a public server not mine I know to a folder on my server so a number of PDFs are stored daily and automatically there with no need for me to use my browser and download locally first using my browser. I know how to create a cron job for any script to run at fixed time intervals but can't figure out what script to assign to the cron for the unattended automatic downloads. Any ideas? Can this be done at all?
Thanks
How to save PDF automatically via cron job or other way?
Moderator: General Moderators
-
litebearer
- Forum Contributor
- Posts: 194
- Joined: Sat Mar 27, 2004 5:54 am
Re: How to save PDF automatically via cron job or other way?
if you KNOW the url for the pdf file, you could use curl in a script that will grab it and save it. the cron could run the script at the appointed time.
Re: How to save PDF automatically via cron job or other way?
I seached for cURL and it seems it has to be installed in the server of which I am not the administrator. Can this be done using file_get_contents instead?
Once I have the file in the 'contents' variable how can I save it as a PDF? Do I need to do something (header configurationm, etc) so the file_get_contents funtion retrieves the PDF in the correct format to save it as PDF? How do I save it as PDF?
Thanks
Once I have the file in the 'contents' variable how can I save it as a PDF? Do I need to do something (header configurationm, etc) so the file_get_contents funtion retrieves the PDF in the correct format to save it as PDF? How do I save it as PDF?
Thanks
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Re: How to save PDF automatically via cron job or other way?
Code: Select all
file_put_contents($file_name_to_save_as, file_get_contents('http://url_of_the.com/document.pdf'));Re: How to save PDF automatically via cron job or other way?
Thanks. Works fine!!John Cartwright wrote:Code: Select all
file_put_contents($file_name_to_save_as, file_get_contents('http://url_of_the.com/document.pdf'));