Home  >  Article  >  Backend Development  >  When using cURL to obtain remote files in PHP, a redirected url is encountered

When using cURL to obtain remote files in PHP, a redirected url is encountered

巴扎黑
巴扎黑Original
2016-11-23 13:10:22885browse

I wrote a simple method using cURL in PHP to get a remote file. I encountered a problem during the test:

That is, if you need to jump to get the actual file URL when getting the remote file, then Can't succeed in obtaining.


How to solve it?

See this web during the process of Google: After reading the URL of PHP CURL to get 301 or 302 )Set CURLOPT_FOLLOWLOCATION.

For option CURLOPT_FOLLOWLOCATION, please see:

http://hk.php.net/manual/en/function.curl-setopt.php


In addition, the main point of the above web discussion The problem is that the PHP settings of the local host caused the Curlopt_followLocation to be unavailable. The solution was proposed. The original focus was as follows:

The acquired DEFAULT SAFE and Default Open Basedir are off. The question is processed.


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn