I have a problem when checking if a file exists in zend framework 2:
When checking:
is_file("/usr/local/zend/apache2/htdocs/my_viena/panel/public/img/familias/101.jpg")
which is the absolute route in my computer, it returns true.
When checking:
is_file($this->basePath()."/img/familias/101.jpg")
which is the route from the module, it returns false.
If I make:
echo "<img src='".$this->basePath()."/img/familias/101.jpg'>";
the browser shows de image correctly.
What is wrong in my code? I want to check if the file exists with the relative route.
In one situation $this->basePath()
will return and empty string. And when checking if your file exists it will search for the absolute path /img/familias/101.jpg
echo "<img src='".$this->basePath()."/img/familias/101.jpg'>";
will show the image because it will load something like this www.yoursite.com/img/familias/101.jpg
public/img/familias/101.jpg
works because everything in zf2 is realtive to the public
folder (I think)
side note don't use echo for creating your tags