PHP check if file exists on my server, based on a full URL
- by stef
I have an app that generates invoices in the form of PDF files stored in a directory on my server. Before mailing out this invoices I'd like to make sure that the URL (not server path) which I store in my DB does indeed point to a valid PDF file.
Something could have gone wrong that wrote a value to that field in the db, but for example the filename is missing; meaning the file is not in the specified directory.
AFAIK file_exists just checks server paths but not URL's.
I could always store the server path too, or assemble it, but I'm wondering if i can do this check based on a full http url ending with a filename?
EDIT: yeah CURL occurred to me too but doesn't that seem a bit heavy for such a simple task? Perhaps I should just store the server path too.