I am writing a PHP program that downloads a pdf from a backend and save to a local drive. Now how do I check whether the file exists before downloading?
Currently I
You can do this with a separate curl HEAD request:
HEAD
curl_setopt($ch, CURLOPT_NOBODY, true); $data = curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
When you actually want to download you can use set NOBODY to false.
NOBODY
false