Skip to end of metadata
Go to start of metadata

file_exists() is useful function can check the availability of a file. Below customized function enables you to check file availability not only local but also remote file as well.


// custom file_exists check file availability (local/remote)

function cfile_exists($url)
{
        if (preg_match("/http/", $url))
        {
                $header_response = @get_headers($url, true);
                if (preg_match("/200 OK/", $header_response[0])) return true;
                else return false;
        }
        else return (file_exists( $url) ? true:false);
}