Search
 
SCRIPT & CODE EXAMPLE
 

PHP

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);
Comment

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);
Comment

PREVIOUS NEXT
Code Example
Php :: print array php 
Php :: php sec into date time 
Php :: laravel https assets 
Php :: npm watch laravel 
Php :: laravel response redirect 
Php :: Add 2 days to the current date in PHP 
Php :: button back php 
Php :: Class "BarryvdhLaravelIdeHelperIdeHelperServiceProvider" not found 
Php :: how to set timezone for iran in laravel 
Php :: wp_query post per page 
Php :: Enable / Disable modules in PHP 
Php :: laravel storage folder permissions 
Php :: group by codeigniter 3 
Php :: disable foreign key laravel 
Php :: get client size in laravel 
Php :: wp max revisions 
Php :: wordpress get username 
Php :: laravel migration change column name 
Php :: laravel make:listner 
Php :: attach multiple files in laravel mailable 
Php :: wordpress post date 
Php :: how get all files name in one folder in laravel 
Php :: remove create in nova resource 
Php :: laravel get public path url 
Php :: php ping time 
Php :: set character set utf8 in pdo php 
Php :: laravel model transaction 
Php :: wordpress query orderby name 
Php :: get product price wordpress 
Php :: Making visible or hidden attributes from Eloquent temporarily 
ADD CONTENT
Topic
Content
Source link
Name
8+6 =