I'm trying to write a PHP script to capture .XLS files from an external site. I was able to design a script using PHP and HTML to automatically submit a query to this URL, http://dsbs.sba.gov/dsbs/search/dsp_dsbs.cfm?
When you're on that page at very bottom it gives you the option to download the search results as an XLS file. When you click submit the file downloads automatically in your browser. I can trigger the file download but am having trouble capturing the results to a web server. I understand
file_put_contents but the file name is only semi predictable. It includes some static wording and then uses a timestamp of hours, minutes and seconds in military time. Even if I try to predict the file name I can't seem to figure out how to capture it and save it to a directory on my server.
I'm asking two questions,
Is there an easy way of figuring out what the filename is when I trigger a download? Currently I just try to predict based off of the exact second the submit is triggered, this is highly inaccurate. Perhaps there's a way to find this information or write a script that will trigger and record the timestamp simultaneously.
This is the most important question, how can I capture the XLS file and save it to my web server instead of having it downloaded in my browser. Keep in mind I'm running this script browser side, I realize running it server side will change the outcome, but will it make it so the file writes to the server?
Thank you for taking the time to read this post and also for any input you may be able to contribute.