我正在开发可下载内容的安全性,以简化我的下载内容。如何在PHP中下载内容的末尾添加额外数据
<?php
$file = 'monkey.gif';
if (file_exists($file)) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($file));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
ob_clean();
flush();
readfile($file);
exit;
}
?>
现在我只是想添加额外的100个字节(我的自定义信息有关下载文件按每次下载)
我想一些方法来添加这些100个字节的ReadFile后($文件);所以下载的文件将会有这个额外的信息。
something like
readfile($file) + myBytes()
我是新来的PHP,请帮我
这取决于您下载的文件的类型。简单地将额外的字节粘贴到文件的末尾可能会导致其被损坏。 –
也许你应该考虑使用安全密钥的加密方法呢? http://stackoverflow.com/questions/2448256/php-mcrypt-encrypting-decrypting-file –