Download di file come allegati con php

Posted on 30. Jun, 2008 by Administrator in php, tutorials


 
< ?php
/*
//Example:
streamAttached('/path/to/file.txt','filename.txt');
*/
function streamAttached($path,$name)
{
    header('Pragma: private');
    header('Cache-control: private, must-revalidate');
    header("Content-Type: application/octet-stream");
    header("Content-Length: " .(string)(filesize($path)) );
    header('Content-Disposition: attachment; filename="'.($name).'"');
    readfile($path);
    exit;
}
?>
 

Via: http://www.sourcerally.net/Scripts/58-Download-files-as-attachments


Correlati

Leave a reply