Search code examples
phpfile-exists

file_exists in php code


I have a simple statement below:

if(file_exists('/images/alum/'.$profile['pic'])) 
  echo '/images/alum/'.$profile['pic']; 
  else echo '/images/user_default.jpg';

The file is there but it's always going to the default image. What have I got wrong?


Solution

  • You are saying on the server that the file at the root of the file system exists. You will have to probably add some . or ..