Page 1 of 1

How to get file extension

Posted: Thu Feb 25, 2010 8:02 pm
by silhoutte
Hello,

I'd like to know how you can get a file extension from a file stored in a url

===========================
For example:

file (john.txt) is stored in this url http://www.warehouse.com/manager/getperson.php?id=12345

If you click on that link it will give you the text file to download.
===========================

The thing is I'd like to know how can I get the extension out of that file (.txt)

file_put_content -> I can save the file ... but I won't know what's the extension
pathinfo() -> only give me the last 4 character in the link

Help please, thank you very much

Re: How to get file extension

Posted: Thu Feb 25, 2010 10:58 pm
by John Cartwright
You need to parse the headers returned, not the request url..

Hint:

Code: Select all

print_r(get_headers($url, 1));