2011-03-04 2 views
0

Bonjour à tous je développe un framework PHP MVC et j'ai atteint un point où je dois offrir à l'utilisateur des fichiers et je ne sais pas comment créer le lien de téléchargement je sais que ça sonne puéril mais J'ai essayé de faire le lien hypertexte à l'adresse du document mais il semble ne pas fonctionner .... Une certaine documentation serait idéaleForcer télécharger un fichier en PHP

Répondre

4
$fullpath = $_SERVER['DOCUMENT_ROOT']."/foldername/document.pdf"; //Full path of document 
$filename = "document.pdf"; //Document file nmae 


    $mm_type="application/octet-stream"; 

    header("Cache-Control: public, must-revalidate"); 
    header("Pragma: hack"); 
    header("Content-Type: " . $mm_type); 
    header("Content-Length: " .(string)(filesize($fullpath))); 
    header('Content-Disposition: attachment; filename="'.$filename.'"'); 
    header("Content-Transfer-Encoding: binary\n"); 
Questions connexes