file-exists

PHP's file_exists() will not work for me?

柔情痞子 提交于 2019-11-26 18:07:30
问题 For some reason this PHP code below will not work, I can not figure it out. It is very strange, file_exists does not seem to see that the image does exist, I have checked to make sure a good file path is being inserted into the file_exists function and it is still acting up If I change file_exists to !file_exists it will return an images that exist and ones that do not exist define('SITE_PATH2', 'http://localhost/'); $noimg = SITE_PATH2. 'images/userphoto/noimagesmall.jpg'; $thumb_name =

Check if file exists on remote server using its URL [duplicate]

爱⌒轻易说出口 提交于 2019-11-26 17:33:11
This question already has an answer here: Checking if a URL exists or not 4 answers How can I check in Java if a file exists on a remote server (served by HTTP), having its URL? I don't want to download the file, just check its existence. import java.net.*; import java.io.*; public static boolean exists(String URLName){ try { HttpURLConnection.setFollowRedirects(false); // note : you may also need // HttpURLConnection.setInstanceFollowRedirects(false) HttpURLConnection con = (HttpURLConnection) new URL(URLName).openConnection(); con.setRequestMethod("HEAD"); return (con.getResponseCode() ==

Check if file exists on remote server using its URL [duplicate]

若如初见. 提交于 2019-11-26 05:28:03
问题 This question already has answers here : Checking if a URL exists or not (4 answers) Closed 3 years ago . How can I check in Java if a file exists on a remote server (served by HTTP), having its URL? I don\'t want to download the file, just check its existence. 回答1: import java.net.*; import java.io.*; public static boolean exists(String URLName){ try { HttpURLConnection.setFollowRedirects(false); // note : you may also need // HttpURLConnection.setInstanceFollowRedirects(false)

How do I check whether a file exists without exceptions?

穿精又带淫゛_ 提交于 2019-11-25 22:15:57
问题 How do I see if a file exists or not, without using the try statement? 回答1: If the reason you're checking is so you can do something like if file_exists: open_it() , it's safer to use a try around the attempt to open it. Checking and then opening risks the file being deleted or moved or something between when you check and when you try to open it. If you're not planning to open the file immediately, you can use os.path.isfile Return True if path is an existing regular file. This follows