php header soru

0 Cevap

Ben aşağıdaki kodu kullanarak benim indirme bağlantıları maskelemek için çalışıyorum.

Bu almost çalışma olduğunu - o dosya boyutu sadece 4kB olduğu indirince doğru ancak dosya almak gibi görünüyor.

Herkes herhangi bir öneriniz sunabilir miyim?

Teşekkürler!

Ayrıca herhangi bir ek bilgiye ihtiyacınız varsa, lütfen bana bildirin - Ben FF3.5.13 kullanarak MAMP bu koşuyorum

<?php

    $filename="download.zip";

    $folder = 'downloads'; 

    $abs_path = $_SERVER['DOCUMENT_ROOT'];
    $path = $abs_path . "/" . $folder ."/" .$filename; // the location of the file.
    $mm_type="application/zip"; //this is for .zip files - Change this for other file types.

    header("Expires: 0");
    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    header("Cache-Control: public");
    header("Content-Description: File Transfer");
    header("Content-Type: " . $mm_type);
    header('Content-Disposition: attachment; filename="'.basename($path).'"');
    header("Content-Length: " . filesize($path)); // **code edited as per comments below**
    header("Content-Transfer-Encoding: binary");

    readfile($path); //Output file for download.

    exit();

?>

GÜNCELLEME: Burada oluşturulan dosyanın içinde ne olduğunu


Warning: filesize() [function.filesize]: stat failed for /Applications/MAMP/htdocs/downloads/download.zip in /Applications/MAMP/htdocs/CURRENT/test.php on line 15

Warning: Cannot modify header information - headers already sent by (output started at /Applications/MAMP/htdocs/CURRENT/test.php:15) in /Applications/MAMP/htdocs/CURRENT/test.php on line 15

Warning: Cannot modify header information - headers already sent by (output started at /Applications/MAMP/htdocs/CURRENT/test.php:15) in /Applications/MAMP/htdocs/CURRENT/test.php on line 16

Warning: readfile(/Applications/MAMP/htdocs/downloads/download.zip) [function.readfile]: failed to open stream: No such file or directory in /Applications/MAMP/htdocs/CURRENT/test.php on line 17

0 Cevap