PHP的exec和返回二进制 [英] Php exec and return binary

查看:148
本文介绍了PHP的exec和返回二进制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图运行在PHP以下

$测试= SVN猫....

现在$测试的输出基本上是由SVN返回的二进制文件。我如何可以下载这个二进制文件。我试图把以下内容:

  $测试=`SVN猫....`
标题(内容处置:附件;文件名=urlen code($文件名));
标题(内容类型:应用程序/强制下载);
标题(内容类型:应用程序/八位字节流);
标题(内容类型:应用程序/下载);
标题(内容说明:文件传输);
回声$测试;


解决方案

的评论关于PHP 的。网络对文档中继()

 标题(内容类型:应用程序/八位字节流);
标题(内容处置:附件;文件名= \\myfile.zip \\);
标题(内容长度:11111);
中继(猫myfile.zip,$ ERR);
出口();

上面code是由Igor在BBOY点茹提供的。

I am trying to run the following in php

$test = svn cat ....

Now the output of $test is basically a binary file returned by svn. How do I make this binary file available as a download. Am trying to put the following:

$test = `svn cat ....`
header("Content-Disposition: attachment; filename=" . urlencode($filename));
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header("Content-Description: File Transfer");            
echo $test;

解决方案

From the comments on PHP.net's documentation on passthru():

header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=\"myfile.zip\"");
header("Content-Length: 11111");
passthru("cat myfile.zip",$err);
exit();

The above code was provided by igor at bboy dot ru.

这篇关于PHP的exec和返回二进制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆