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

梦想与她 提交于 2019-12-25 02:19:44

问题


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 your assistance.


回答1:


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.



来源:https://stackoverflow.com/questions/6182839/in-php-output-as-byte-array-and-stream-which-one-is-better

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!