Try something like this: $myfilename="c-form".date('m-d-Y_hia').'.txt'; // collect the data to the be returned to the user, no need to save to disk // unless you really want to, if so, use file_put_contents() $dataForFile="test data to be returned to user in a file"; header('Content-type: application/x-download');. example:: /path/to/file/ or * @param string $data The data to write. * * @param int $flags same flags used for file_put_contents. * more info: php * @return bool TRUE file created succesfully FALSE failed to create. 17 Feb Hi Guys, I am trying to create a csv file and force the download in the users browser (should also be compatible with IE7). Does anyone know how this can be done?.
17 Aug Using a force-download script, you can: validate that a person is logged in, increment a counter in a text file, connect to your database and log IP information Just to test different issues – I created a simple “email that to me” php script which executes the same query and attaches the doc to the email (using. 1 Sep If you need to restrict access to a file, you should generate encrypted, one-time IDs, so you can be sure a generated path can be used only once. header(" Content-Type: application/force-download"); header("Content-Type: application/ octet-stream"); header("Content-Type: application/download");. 15 Mar How to use PHP and the Content-disposition HTTP header to force files to download that would normally open in the web browser and display inline.