Answers for "download file word in php"

PHP
1

create and download text file in php

$file = "test.txt";
$txt = fopen($file, "w") or die("Unable to open file!");
fwrite($txt, "lorem ipsum");
fclose($txt);

header('Content-Description: File Transfer');
header('Content-Disposition: attachment; filename='.basename($file));
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
header("Content-Type: text/plain");
readfile($file);
Posted by: Guest on November-18-2020
1

download file in php

$filename = 'test.txt';

header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($filename));
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pregma: public');
header('Content-Length: '. filesize($filename));
readfile($filename);
exit();
Posted by: Guest on December-02-2021

Browse Popular Code Answers by Language