-1

file_exists is working for some files and not others.

To illustrate I'll limit it to two files:

Image1.png

Image2.png

Running file_exists("Image1.png") works, however running file_exists("Image2.png") fails.

Both files have the same permissions. A copy of Image1.png named ImageA.png will return the right result, a newly created file will fail.

This is on a Windows server. I had copied the files from a linux server. I installed cygwin and chmoded everything to 755 just in case... same result.

Any ideas?

Community
  • 1
  • 1
BOMEz
  • 1,020
  • 14
  • 34

2 Answers2

0

Returns TRUE if the file or directory specified by filename exists; FALSE otherwise.file_exists() needs to use a file path

<?php
$filename = '/path/to/image2.png';


if (file_exists($filename)) {
echo "The file $filename exists";
} else {
    echo "The file $filename does not exist";
}

?>

more REF :http://php.net/manual/en/function.file-exists.php

PHP's file_exists() will not work for me?

Community
  • 1
  • 1
channasmcs
  • 1,104
  • 12
  • 27
0

I figured it out. I thought it didn't apply to me but it turns out it was file permissions. I had to go into the advanced windows file permissions and get them set.

If you bump into this along with thousands of others and think it's not file permissions and that you've checked them...go check them again.

BOMEz
  • 1,020
  • 14
  • 34