In PHP, cURL is used to write a simple method to obtain a remote file. A problem occurs during the test: if you need to jump to the remote file to obtain the actual file url, the file cannot be obtained successfully. how can this problem be solved? In the process of Google, you can see this web: after reading about the problem of getting the 301 or 302 redirection URL of phpcurl, you can find the solution through c... in PHP, cURL is used to write a simple method to obtain a remote file. A problem occurred during the test:
That is, if you need to jump to the remote file to get the actual file url, the file cannot be obtained successfully.
How can this problem be solved?
In the Google process, we can see this web: it is difficult for php curl to obtain the 301 or 302 redirection URL.
After reading this article, I learned the solution, that is, using curl_setopt () to set CURLOPT_FOLLOWLOCATION.
For option CURLOPT_FOLLOWLOCATION, see:
Http://hk.php.net/manual/en/function.curl-setopt.php
In addition, the main problem discussed on the web above is that the PHP settings of the local host make CURLOPT_FOLLOWLOCATION unusable,
The solution is proposed. The original article focuses on the following:
If the Default Safe and Default Open BaseDir values are both OFF, the problem will be handled.