• I need some help please with file_exists function that doesn’t works. I can’t figure it out why. I think my code is correct. Please help me!

    my code is:

    <?php
     if ( file_exists( "https://localhost/turbo/wp-content/uploads/car.jpg" ) ) {
        echo 'image exists';
     } else {echo 'image not found';}
     ?>

Viewing 1 replies (of 1 total)
  • It’s most likely becuase you’re using a URL and not a file path. Some servers have retrictions on thatt so it will block calls to URL’s.

    The way to do it correctly would be to use something like this:

    <?php
     if ( file_exists( ABSPATH . "/wp-content/uploads/car.jpg" ) ) {
        echo 'image exists';
     } else {echo 'image not found';}
     ?>
Viewing 1 replies (of 1 total)
  • The topic ‘FILE_EXISTS doesn't works in wordpress…pls help me!’ is closed to new replies.