0

I am developing a security for my downloadable contents simply securing my download content like this.

<?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;
}
?>

Now I simply want to add 100 extra bytes (my custom details about that download file as per each download)

I want some way to add these 100 bytes after readfile($file); so downloaded file will have this extra information in it.

something like 
readfile($file) + myBytes()

I am new to PHP so please help me

4

2 回答 2

2

将多余的字节存储在文件、变量、数据库等中,并在读取文件功能后回显它

$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);
    readfile("extra_filename.ext");
    /* 
    //or use this
    $extra_bytes = "store extra bytes here";
    echo $extra_bytes;
    */
    exit;
}
于 2012-11-02T18:25:13.153 回答
0

如果您只处理图像,我建议您使用steganography而不是将字节粘贴到文件末尾。谷歌搜索“php 隐写库”出现了一些点击:

于 2012-11-02T17:35:41.773 回答