dadamssg Posted April 2, 2012 Share Posted April 2, 2012 What's the proper way to check if a file exists on a remote server? I know file_exists() works for you local files. I think i need to use something like the following. BUT if the file is not found PHP throws a warning. I know i can put a '@' before fopen() but that just masks the error. <?php if(fopen("http://www.othersite.com/imageXYZ.jpg", "r")) { echo "File exists."; } else { echo "File does not exist."; } ?> Link to comment https://forums.phpfreaks.com/topic/260165-file-exists-on-a-remote-server/ Share on other sites More sharing options...
NomadicJosh Posted April 2, 2012 Share Posted April 2, 2012 Have you looked into using CURL or ftp_nlist? Link to comment https://forums.phpfreaks.com/topic/260165-file-exists-on-a-remote-server/#findComment-1333442 Share on other sites More sharing options...
trq Posted April 2, 2012 Share Posted April 2, 2012 file_exists works fine (since 5.0) providing you have url wrappers enabled. Link to comment https://forums.phpfreaks.com/topic/260165-file-exists-on-a-remote-server/#findComment-1333489 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.