0

Here is the code I have for that, but it never returns true.

    $image = $_FILES['image'];

    $filename = $image['name'];
    $filepathname = "/$membername/"."$filename";

    if (file_exists($filepathname)) {
       throw new Exception('Image already exists');
    }
John Conde
  • 207,509
  • 96
  • 428
  • 469
  • Search "relative path": http://www.google.com/search?client=safari&rls=en&q=relative+path&ie=UTF-8&oe=UTF-8 – jeremy Sep 04 '12 at 23:44
  • 1
    Also you don't want to use user-supplied values directly for any path operations. Filter, at least `basename`. – mario Sep 04 '12 at 23:48
  • Why do you think it should return true for you? Does `file_exists($knownExistingFilename)` return true? Does `knownExistingFilename` match the value of `filepathname` above? – Explosion Pills Sep 05 '12 at 00:46

1 Answers1

0

Does "$membername" contain the $_SERVER['DOCUMENT_ROOT'] path?

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

(if it does contain the $_SERVER['DOCUMENT_ROOT'] then you may want to check the file permission - assuming that you are using LAMP)

Community
  • 1
  • 1
Renon Stewart
  • 17,426
  • 2
  • 44
  • 61