通过https通过PHP下载Excel文件

时间:2018-10-04 22:34:33

标签: php excel https download

我将要使用一个我一直在使用的Web应用程序,现在,当然,现在要更新代码以使在我的localhost上可以正常运行的事情在安全服务器上运行。该应用程序执行的任务之一是生成和下载文件。所有文件都已生成并写入服务器,但是.xls,.csv和.json文件下载时没有数据,即使数据在服务器上的文件中也是如此。 .xml,.zip和.sql文件确实会下载准确的数据。包含在.zip文件中的.xls或.json文件可以。由于我使用的是Chrome,因此此问题并非特定于IE。还尝试了Safari,但结果相同。

这是我要下载Excel的工作:

$excel_content = file_get_contents($download_file_name);
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=\"".$file_name);
header("Content-Transfer-Encoding:  binary");
header("Pragma: no-cache");
header("Expires: 0");
print chr(255).chr(254).mb_convert_encoding($excel_content, 'UTF-16LE', 'UTF-8');

这是我要下载的XML:

$xml_content = file_get_contents($download_file_name);
header("Content-Type: application/xml");
header("Content-Disposition: attachment; filename=\"".$file_name);
header("Content-Transfer-Encoding: UTF-8");
header("Pragma: no-cache");
header("Expires: 0");
print $xml_content;

谁能看到Excel为什么可以在我的本地主机上运行,​​而不能通过https协议在我的服务器上运行吗?如果有关系,我确实已启用openssl,并已通过服务器上的info.php文件进行了验证。

0 个答案:

没有答案