Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/247.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/http/4.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_Http_Wireshark - Fatal编程技术网

Php 客户端缺少内容处置标头

Php 客户端缺少内容处置标头,php,http,wireshark,Php,Http,Wireshark,我有一个php add,它调用LaTeX,然后将PDF传递到浏览器。由于我的用户将为此服务付费,我想确保他们可以选择保存PDF,而不是一次又一次地点击我的服务器 exec("cd tex && latex {$_SESSION['sen_id']}.tex && pdflatex {$_SESSION['sen_id']}.tex", $output); $pdf = substr($file,0,-3).'pdf'; if (file_exists($pdf))

我有一个php add,它调用LaTeX,然后将PDF传递到浏览器。由于我的用户将为此服务付费,我想确保他们可以选择保存PDF,而不是一次又一次地点击我的服务器

exec("cd tex && latex {$_SESSION['sen_id']}.tex && pdflatex {$_SESSION['sen_id']}.tex", $output);
$pdf = substr($file,0,-3).'pdf';
if (file_exists($pdf)) {
  //header('Content-Description: File Transfer');
  header('Content-Type: application/pdf');
  //header('Content-Length: ' . filesize($pdf));
  header('Content-Disposition: attachment;filename='.date('Ymd-His').'-'.basename($pdf));
  header('Content-Transfer-Encoding: binary');
  header('Expires: 0');
  header('Cache-Control: no-cache');
  header('Pragma: no-cache');
  ob_clean();
  flush();
  readfile($pdf);
  exit;
} else {
  echo '<h1>No PDF Produced</h1>';
  echo nl2br(print_r($output,true));
}
exec(“cd-tex&&latex{$\u SESSION['sen\u id']}.tex&&pdflatex{$\u SESSION['sen\u id']}.tex”,$output);
$pdf=substr($file,0,-3)。'pdf';
如果(文件存在($pdf)){
//标题(“内容描述:文件传输”);
标题(“内容类型:应用程序/pdf”);
//标题('Content-Length:'.filesize($pdf));
标题('Content-Disposition:attachment;filename='.date('Ymd-His').-'.basename($pdf));
标题(“内容传输编码:二进制”);
标题('Expires:0');
标头(“缓存控制:无缓存”);
标题('Pragma:no cache');
ob_clean();
冲洗();
readfile($pdf);
出口
}否则{
echo“未生成PDF”;
echo nl2br(打印($output,true));
}
使用Wireshark,我注意到Content Disposition标头未设置或未到达客户端

HTTP/1.1 200 OK\r\n
Date: Tue, 22 Jun 2010 14:15:10 GMT\r\n
Server: Apache/2.0.55 (Ubuntu) mod_jk/1.2.14 mod_python/3.1.4 Python/2.4.3 PHP/5.1.2 mod_ssl/2.0.55 OpenSSL/0.9.8a mod_perl/2.0.2 Perl/v5.8.7\r\n
X-Powered-By: PHP/5.1.2\r\n
Set-Cookie: SESS0d6c65b0599f5b70f6bbc50cfc5b2f94=2b23ba1f74f5f1f641365e9fbb45870d; expires=Thu, 15 Jul 2010 17:48:30 GMT; path=/; domain=.<domain removed>\r\n
Content-Transfer-Encoding: binary\r\n
Expires: 0\r\n
Cache-Control: no-cache\r\n
Pragma: no-cache\r\n
Connection: close\r\n
Transfer-Encoding: chunked\r\n
Content-Type: application/pdf\r\n
\r\n
HTTP/1.1 200正常\r\n
日期:2010年6月22日星期二14:15:10 GMT\r\n
服务器:Apache/2.0.55(Ubuntu)mod_jk/1.2.14 mod_python/3.1.4 python/2.4.3 PHP/5.1.2 mod_ssl/2.0.55 OpenSSL/0.9.8a mod_perl/2.0.2 perl/v5.8.7\r\n
X-Powered-By:PHP/5.1.2\r\n
设置Cookie:SESS0d6c65b0599f5b70f6bbc50cfc5b2f94=2b23ba1f74f5f641365e9fbb45870d;expires=2010年7月15日星期四格林威治标准时间17:48:30;路径=/;域=。\r\n
内容传输编码:二进制\r\n
过期:0\r\n
缓存控制:没有缓存\r\n
Pragma:没有缓存\r\n
连接:关闭\r\n
传输编码:分块\r\n
内容类型:应用程序/pdf\r\n
\r\n

到目前为止,我发现的提示是“使用八位字节流”、“不使用八位字节流”、“在冒号后面加空格”、“大写每个单词”和“将文件名括在引号中”。我想运气好的人可能会发布很多错误信息。

我不知道为什么要删除标题,但描述了如何在内容处置标题中编码文件名及其对浏览器互操作性的影响

在这些情况下,我选择了在PHP手册页面中编写的解决方案(参见第一个示例)


在中,您使用的标头无效,但是,它应该适用于所有主要浏览器。

我不知道为什么要删除标头,但介绍了如何在内容处置标头中编码文件名及其对浏览器互操作性的影响

在这些情况下,我选择了在PHP手册页面中编写的解决方案(参见第一个示例)

在中,您使用的标题无效,但是,它应该适用于所有主要浏览器