Codeigniter always runs on index.php , so all paths are relative to it. You can use any of the following values if upload/ is at the index.php level:
file_exists("upload/$id.jpg")
file_exists("./upload/$id.jpg")
file_exists(FCPATH."upload/$id.jpg")
FCPATH is the constant that Codeigniter sets that contain the absolute path to your index.php .
As a side note, I prefer is_file() when checking files, since file_exists() returns true in directories. In addition, you can see if getimagesize() returns FALSE to make sure you have an image.
Wesley murch
source share