Saltern Saltern - 7 months ago 22
PHP Question

Check exist file with php

I want to check exist file with php or yii2

filesize
and
is_file
and
file_exists
are not working !

filesize
error is :
filesize(): stat failed for....


is_file
and
file_exists
return false !

This is my code :

$fileI = $urlBase . "$home/../siteImage/$logo";


$fileI is :

http://localhost/iicitySite/web/index.php/../siteImage/parvaz.png


$home is :

$home -> /iicitySite/web/index.php


This is has correct image in view :

echo "



<div class='col-lg-12 col-xs-12 col-sm-12 col-md-12 forsatItem'>
<div class='backItem'>
<div class='rightM col-lg-4'>
<div class='imgForsat'>
<img src='$home/../siteImage/$logo' alt=''/>
</div>


.
.
.
.

Answer

Try this

$url = 'http://www.example.com';//or file path
$headers = get_headers($url, 1);
print_r($headers);//$headers[0] u will get the status

Source: link

Comments