In PHP, when cURL is used to obtain remote files, the redirection url is displayed.

Source: Internet
Author: User
Tags file url
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.