get the file extension during php download


I try to add the file extension to my file during the download. As I find it hard to do, I already coded it in a small .jpeg case in my script. How can I get rid of the hard coded file extension and dynamically replace it with the original loaded as it could be gif, pdf etc.

The answer

$_FILES['file']['tmp_name'] that you use contains a temporary file name for the downloaded file. But if you want the original filename, including the extension, use $_FILES['file']['name'] .

Related articles

Why change the file extension during the download?


Hello, I would be happy in taking the support of the following problem: When I try to download, for example, a pdf / mov / zip, etc. everything is fine. When I try to download a * .x83 file (this is a file extension for the bids), Firefox seems to ch

How do I get a file extension in Marklogic Server?


I want to get the file extension of the downloaded file into the Marklogic server. I know how to get the file name. But this gives filename more extension like new.txt. But I do want the extension, not the full name of the file. How do I get just the

Firefox changes file extension during download


We build a web application where you can download different types of files, for example PDF and DOCX files. Direct links are provided to them. In Chrome, IE, Opera - all files download as expected (or open if there is a specific setting for this type