Discover php check if remote file exists, include the articles, news, trends, analysis and practical advice about php check if remote file exists on alibabacloud.com
This article gives you the content is about how to check the existence of the remote file in PHP (pure code), there is a certain reference value, the need for a friend can refer to, I hope you have some help.
Check if the remote file exists
PHP uses the get_headers function to determine whether a remote file exists ,. PHP uses the get_headers function to determine whether a remote file exists. this example describes how PHP uses the get_headers function to determine whether a remote
Copy CodeThe code is as follows:
Judging remote Files
function Check_remote_file_exists ($url)
{
$curl = Curl_init ($url);
Do not retrieve data
curl_setopt ($curl, Curlopt_nobody, true);
Send Request
$result = curl_exec ($curl);
$found = false;
If
PHP determines whether a remote image file exists. The simplest method of the fopen () method is to use fopen () to check whether the file can be opened. if the file can be opened, the file will certainly exist .? Php?urlwww.bkjia.comimagestest.jpg;
PHP to determine the existence of remote images, this method is also applicable to determine the existence of remote files, which is an efficient and accurate method, it is recommended to use this method, previously used Get_headers () method to
This example describes how PHP uses the Get_headers function to determine whether a remote file exists. Share to everyone for your reference. The implementation method is as follows:
Before the process about PHP to determine whether remote files
The code is as follows:
Judging remote Files
function Check_remote_file_exists ($url)
{
$curl = Curl_init ($url);
Do not retrieve data
curl_setopt ($curl, Curlopt_nobody, true);
Send Request
$result = curl_exec ($curl);
$found = false;
If the
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.