curl - How to read xls file return by Content-Disposition: attachment with PHP
Get the solution ↓↓↓Solution:
To download a file using curl in php you have to use code which is like so:
<?php
//File to save the contents to
$fp = fopen ('theFile.xls', 'w+');
$url = "https://demo.com/report?transType=xls";
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, $url );
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
//give curl the file pointer so that it can write to it
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$data = curl_exec($ch);//get curl response
//done
curl_close($ch);
fclose($fp);
?>
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: a non-numeric value encountered
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.