Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Sep 2012
    Posts
    76
    Thanks
    61
    Thanked 0 Times in 0 Posts

    Checking a file exists?

    Hello, I'm looking for some help please.

    I wish to check 2 absolute paths to images on two different servers of mine. If it exists in the first path then I'd echo a message, but if no file is found then I'd check the second path and echo a message if it's found. If that's not found I'd show a Final message saying no file found.

    However I've tried using file_exists and I always seem to get a message that no file is found despite a file definitely being there. Can anyone help and advise here please?

    Thank you

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    file_exists won't work on a remote machine; it is listed as belonging to the stat family, and as such are not supported by http protocol. You can use the ssh2.sftp protocol though.

  • Users who have thanked Fou-Lu for this post:

    Oatley (01-15-2013)

  • #3
    New Coder
    Join Date
    Sep 2012
    Posts
    76
    Thanks
    61
    Thanked 0 Times in 0 Posts
    Ok, have found the answer and can use fopen(). Just another question on this though please. I plan to use this check on several images on my front page of my website like this. Is using fopen() here like this on several images putting a huge strain on my server?

    Thanks

  • #4
    New Coder
    Join Date
    Sep 2012
    Posts
    76
    Thanks
    61
    Thanked 0 Times in 0 Posts
    Thanks Fou-Lu. Must have both replied at the same time!

  • #5
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Sure, I mean you're using fopen remotely so each check has to go out and connect to the remote machine. Its no different than navigating to a website and loading an image, the only difference is you are not actually moving the data.
    BTW, it will also only work remotely if you have allow_url_fopen enabled, and it must be served via the HTTPD on the remote machine. Otherwise use sockets.

  • Users who have thanked Fou-Lu for this post:

    Oatley (01-15-2013)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •