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

Portable way to check if directory exists [Windows/Linux, C]

stat() works on Linux., UNIX and Windows as well: #include <sys/types.h> #include <sys/stat.h> struct stat info; if( stat( pathname, &info ) != 0 ) printf( “cannot access %s\n”, pathname ); else if( info.st_mode & S_IFDIR ) // S_ISDIR() doesn’t exist on my windows printf( “%s is a directory\n”, pathname ); else printf( “%s is no … Read more

Deleting a file in VBA

1.) Check here. Basically do this: Function FileExists(ByVal FileToTest As String) As Boolean FileExists = (Dir(FileToTest) <> “”) End Function I’ll leave it to you to figure out the various error handling needed but these are among the error handling things I’d be considering: Check for an empty string being passed. Check for a string … Read more

tech