0

Pretty much explains itself. If I just just get the image to load with this:

<img src="/dm cricket/admin/img/tables/<?php htmlout($name);?>_2.jpg">

it works, but if I decide to change the code to this:

<?php if(file_exists('/dm cricket/admin/img/tables/'.$name.'_2.jpg')){
    ?>
<img src="/dm cricket/admin/img/tables/<?php htmlout($name);?>_2.jpg"><?php }
else {
    echo 'No competition held';}?>

it doesn't work, it only echoes 'No competition held'. Can anyone explain why?

3
  • You should avoid using spaces in URLs. Commented Jan 10, 2013 at 12:14
  • I know, but it that relevant to the question? Commented Jan 10, 2013 at 12:16
  • A hint for you: Your document root is problably not your filesystem root. Commented Jan 10, 2013 at 12:18

1 Answer 1

1

A root relative URI from the URI of the page as fetched over HTTP is not going to be the same thing as a file path on the file system of the web server.

Assuming a simple configuration of the server, you would have to prefix the file path with the path to the server's web root directory.

Sign up to request clarification or add additional context in comments.

1 Comment

Ah ok, I get it. Added the following to the front of the directory and it worked $_SERVER['DOCUMENT_ROOT'] .

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.