开发者

In PHP, output as byte array and stream. Which one is better?

i need to write a php web service to output file to a Windows client application. I have two choice Byte Array and Streaming. Which one is better and easy to implement in PHP?

Thanks for 开发者_StackOverflow社区your assistance.


How about just....

$file = 'some_file.exe';

$_size = filesize($_file);
header('Content-Type: binary/octet-stream');
header('Content-Length: '.$_size);
header('Content-Disposition: attachment; filename="' . basename($file) . '"; size=" . $_size);

@readfile($file);

Note: see the comment about some issues with binary files, however.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜