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
How to get file extension
Moderator: General Moderators
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Re: How to get file extension
You need to parse the headers returned, not the request url..
Hint:
Hint:
Code: Select all
print_r(get_headers($url, 1));