I have an application that creates invoices as PDF files stored in a directory on my server. Before sending out these invoices, I would like to make sure that the URL (not the server path) that I store in my database really points to a valid PDF file.
Perhaps something went wrong that wrote the value for this field in db, but, for example, the file name is missing; this means that the file is not specified in the specified directory.
AFAIK file_exists just checks server paths, but not URLs.
I could always store the server path or collect it, but I wonder if I can do this check based on the full http url ending with the file name?
EDIT: Yes, CURL also crossed my mind, but isn't it too hard for such an easy task? Maybe I should just save the server path.
source
share