How to check if a file exists from a url

You don’t need CURL for that… Too much overhead for just wanting to check if a file exists or not… Use PHP’s get_header. $headers=get_headers($url); Then check if $result[0] contains 200 OK (which means the file is there) A function to check if a URL works could be this: function UR_exists($url){ $headers=get_headers($url); return stripos($headers[0],”200 OK”)?true:false; } …

Read more

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

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() == HttpURLConnection.HTTP_OK); } catch (Exception e) { e.printStackTrace(); return false; } } If the connection to a URL (made with HttpURLConnection) returns with HTTP status …

Read more

How to check whether file exists in Qt in c++

(TL;DR at the bottom) I would use the QFileInfo-class (docs) – this is exactly what it is made for: The QFileInfo class provides system-independent file information. QFileInfo provides information about a file’s name and position (path) in the file system, its access rights and whether it is a directory or symbolic link, etc. The file’s …

Read more