oldcelt Posted July 11, 2020 Share Posted July 11, 2020 (edited) I've read as many previous posts as I can find and tried all the suggested solutions but the following simple test code will not work for me (the session variable has been echoed and is correct). Instead of echoing the correct answer, the if(file_exists($target_file)) skips the true result and always displays the false one. I've tested it with files that do and don't exist of course. Here is the code :- $filename = $_SESSION["filename"]; $target_file = $_SERVER['CONTEXT_DOCUMENT_ROOT'] . '/folder/' . $_SESSION["filename"]; if (file_exists($target_file)) { echo 'Selected file is ' . $filename . ' and will be written.'; } else { echo "Selected file " . $filename . " doesn't exist."; } I'd really appreciate any help on this please. Edited July 11, 2020 by oldcelt Quote Link to comment Share on other sites More sharing options...
maxxd Posted July 11, 2020 Share Posted July 11, 2020 I've never heard of $_SERVER['CONTEXT_DOCUMENT_ROOT'] and it's not listed in the documentation - echo that out and see what it says. Quote Link to comment Share on other sites More sharing options...
gizmola Posted July 11, 2020 Share Posted July 11, 2020 6 hours ago, maxxd said: I've never heard of $_SERVER['CONTEXT_DOCUMENT_ROOT'] and it's not listed in the documentation - echo that out and see what it says. There is some information about it. I agree that step one on this is to echo out $target_file, and determine if that file exists on the file system. Quote Link to comment Share on other sites More sharing options...
maxxd Posted July 12, 2020 Share Posted July 12, 2020 2 hours ago, gizmola said: There is some information about it. Hunh - got some reading to do. Thanks for the pointer! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.