I create a file on the fly in PHP containing plain text and then tell the browser to download it using the following code:
# Create the verification file and force-download it. header("Content-type: text/plain"); header("Content-Disposition: attachment; filename='.ecf'"); #1 header("Pragma: no-cache"); header("Expires: 0"); echo "...";
As shown on line with #1 , I want the download file to be named .ecf , but with my current code, when it loads with the name ecf (without extension).
How can I tell PHP to save the file as .ecf instead of ecf ?
Note. The problem that I am facing is that the downloaded file does not have an extension, and is not trying to create and upload the file on the fly, so please refrain from marking this question as duplicating many existing questions regarding this.
Edit: As also pointed out in the comments, I tried to escape the dot, but then the downloaded file has the name -.ecf .
source share