Answers for "php if image url not exist"

PHP
2

check image is available on server php

if (file_exists('http://www.mydomain.com/images/'.$filename)) {
 … }
Posted by: Guest on June-27-2020
0

php check if image exists on remote server

function remote_file_exists($url)
{
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_NOBODY, true);
    curl_exec($ch);
    $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    curl_close($ch);
    if( $httpCode == 200 ){return true;}
}

//THE USE THE BELOW FUNCTION CALL

if(remote_file_exists($url))
{
    //file exists, do something
}
Posted by: Guest on August-07-2020

Browse Popular Code Answers by Language