Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/261.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 下载文件,不保存在服务器中_Php_Header - Fatal编程技术网

Php 下载文件,不保存在服务器中

Php 下载文件,不保存在服务器中,php,header,Php,Header,或者用户可以下载文件而不将其保存在服务器上? 我正在从数据库获取数据,我想保存它们.doc(MS Word)文件 } 如果没有以下内容,代码应该是什么样子: “$fh=fopen($file,'w'); fwrite($fh,$stringData); fclose($fh);” 还有这个“取消链接($file);” 我希望了解我需要什么 在此处输入代码您只需输出标题,然后输出内容: header(...); echo $stringData; 无需播放任何文件。您只需输出标题,然后输出内容

或者用户可以下载文件而不将其保存在服务器上? 我正在从数据库获取数据,我想保存它们.doc(MS Word)文件

}

如果没有以下内容,代码应该是什么样子: “$fh=fopen($file,'w');
fwrite($fh,$stringData); fclose($fh);” 还有这个“取消链接($file);”

我希望了解我需要什么
在此处输入代码

您只需输出标题,然后输出内容:

header(...);

echo $stringData;

无需播放任何文件。

您只需输出标题,然后输出内容:

header(...);

echo $stringData;
header("Content-type: application/octet-stream");    
header("Content-Disposition: attachment; 
filename=\"$_fileName\"");
ob_clean();
readfile($_filePath);
不需要玩任何文件

header("Content-type: application/octet-stream");    
header("Content-Disposition: attachment; 
filename=\"$_fileName\"");
ob_clean();
readfile($_filePath);