Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-15-2013, 03:18 PM   PM User | #1
Oatley
New Coder

 
Join Date: Sep 2012
Posts: 76
Thanks: 61
Thanked 0 Times in 0 Posts
Oatley is an unknown quantity at this point
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
Oatley is offline   Reply With Quote
Old 01-15-2013, 03:37 PM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,741
Thanks: 4
Thanked 2,465 Times in 2,434 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
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.
Fou-Lu is offline   Reply With Quote
Users who have thanked Fou-Lu for this post:
Oatley (01-15-2013)
Old 01-15-2013, 03:37 PM   PM User | #3
Oatley
New Coder

 
Join Date: Sep 2012
Posts: 76
Thanks: 61
Thanked 0 Times in 0 Posts
Oatley is an unknown quantity at this point
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
Oatley is offline   Reply With Quote
Old 01-15-2013, 03:39 PM   PM User | #4
Oatley
New Coder

 
Join Date: Sep 2012
Posts: 76
Thanks: 61
Thanked 0 Times in 0 Posts
Oatley is an unknown quantity at this point
Thanks Fou-Lu. Must have both replied at the same time!
Oatley is offline   Reply With Quote
Old 01-15-2013, 03:40 PM   PM User | #5
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,741
Thanks: 4
Thanked 2,465 Times in 2,434 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
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.
Fou-Lu is offline   Reply With Quote
Users who have thanked Fou-Lu for this post:
Oatley (01-15-2013)
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:13 PM.


Advertisement
Log in to turn off these ads.