Home >>Advance PHP Tutorial >PHP Download File

PHP Download File

PHP File Downloading

 <?php

       $f="resume.doc";   

       $file = ("myfolder/$f");

       $filetype=filetype($file);

       $filename=basename($file);

       header ("Content-Type: ".$filetype);

       header ("Content-Length: ".filesize($file));

       header ("Content-Disposition: attachment; filename=".$filename);

       readfile($file);

  ?>	

Suppose You have a directory inside with collection of multiple related Files . Display all stored files using opendir( ) and readdir( ) function. Download those particular file on which user has clicked.(It means download the files dynamically not a static file)


No Sidebar ads