did you bother looking at the maunal page for [man]file_exists[/man]. it says:

As of PHP 5.0.0 this function can also be used with some URL wrappers. Refer to Appendix L for a listing of which wrappers support stat() family of functionality.

    4 years later

    And that statement means what exactly...

    I can;t work out how to use "file_exists" on remote files.

      It means exactly what it says; if you have PHP 5.0.0 or greater, you can use [man]file_exists/man on some URL wrappers. Which ones? Visit this manual page to find out if the wrapper in question supports stat(): [man]wrappers[/man].

      EDIT: If the answer is no, then no, you can't use file_exists() with the wrapper you wanted to and you'll have to find other means of ascertaining whether or not that remote file exists.

      (For HTTP(S), you could use [man]cURL/man, set CURLOPT_NOBODY to false, CURLOPT_HEADER to true, CURLOPT_RETURNTRANSFER to true, and check if "HTTP/1.1 200" is returned - otherwise you could say the didn't exist.)

        Could someone please give an example of exactly HOW 'file_exists' can be used to determine if a remote file exists using a 'stat() wrapper'.

        The manual really doe not help!

          icomnia wrote:

          Could someone please give an example of exactly HOW 'file_exists' can be used to determine if a remote file exists using a 'stat() wrapper'.

          Read bradgrafelman's post and do what he says in the first two paragraphs.

            Thanks for that...

            No - I can not understand WHAT wrappers are & HOW they are used.

            In leyman's terms - what is a wrapper?

            I have fopen_url enabled on my server.

            But file_exists still will not validate a remote file.

              iceomnia wrote:

              No - I can not understand WHAT wrappers are & HOW they are used.

              The word "wrappers" is linked in bradgrafelman's post.

              iceomnia wrote:

              But file_exists still will not validate a remote file.

              So ... you followed the link to [man]file_exists[/man], you followed the link to [man]wrappers[/man]. You determined whether or not the wrapper in question supports stat(). What was your answer? If the answer is no, then no, you can't use file_exists() with the wrapper you wanted to and you'll have to find other means of ascertaining whether or not that remote file exists.

                Write a Reply...