I have an PHP Yii2 webapplication, which runs an command line script using passthru()
. The passthru()
result should passed into an downloaded file, so that the user can download the output of passthru()
.
Example:
If I execute the following command line:
$ /bin/cat /PATH/pic.jpg > output.jpg
...I get an file output.jpg
, which is identical to pic.jpg
(same md5 checksum)
But I need to execute this mechanism in an web application:
If I doing the same using passthru()
in order to send the file to the users browser:
header("Cache-Control: private");
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=download.jpg");
passthru ('/bin/cat /PATH/pic.jpg');
....than I get an download.jpg
which is not the same like pic.jpg
I this example-case download.jpg
is 1126 bytes smaller (picture size is around 13MBytes) and the picture can not be opend in some picture viewer.