I'm leveraging PHP to try and save the result I'm presented with when visiting a URL instead of having to choose 'Save As'.
I'm working with a URL that has a number of variables that a user can modify and once the user has chosen their options, the URL is concatenated for use but there seems to be no way to retrieve the data using curl
or any of the file
functions, however if the user were to manually click a link generated by my script or paste the URL into their browser, they are presented with a browser prompt to save the extentionless file.
I've been working with curl
to try and download the return from the URL with no success and displaying curl_getinfo
shows the following:
[url] => REMOVED-FOR-REASONS-?startDate=08-01-2015&endDate=09-01-2015&format=csv
[content_type] =>
[http_code] => 0
[header_size] => 0
[request_size] => 0
[filetime] => 0
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 0
[namelookup_time] => 0
[connect_time] => 0
[pretransfer_time] => 0
[size_upload] => 0
[size_download] => 0
[speed_download] => 0
[speed_upload] => 0
[download_content_length] => -1
[upload_content_length] => -1
[starttransfer_time] => 0
[redirect_time] => 0
[redirect_url] =>
[primary_ip] =>
[certinfo] => Array
(
)
[primary_port] => 0
[local_ip] =>
[local_port] => 0
I switched over to file_get_contents
and file_put_contents
and the resulting file is nothing more than the HTML used to display the page you would see if you were creating the file at the destination URL as if the user never submitted the form; the corresponding file that the user would download is not returned.
As there is no file generated on the target server, the data I am trying to capture is just a return of the requested data in a format that can be saved, conveniently, with a csv extension, can I use curl
or the file
commands?