I have a cURL request:
$ch = curl_init('http://domain.com/file.ext');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FAILONERROR, true);
$response = curl_exec($ch);
$contentType = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
$extension = '?' // How?
and want to get the extension of URL, based on content type, but how?
I have read about some regex, but, if my file have multiple dots, or extensions, like:
file.renamed.with.multiple.dots.png
file.zip.rar
And, if I have a file like file.ext
and known the content type is image/png
, but the extension is not png
?
Thanks!