Wednesday, 3 July 2013

Force download any file in php

//$file = $filepath . $filename;
$file = $downloadFilePath;
$logger->info("downloadFilePath::::".$downloadFilePath);
//CREATE/OUTPUT THE HEADER
header("Content-type: application/force-download");
header("Content-Transfer-Encoding: Binary");
header("Content-length: ".filesize($file));
header("Content-disposition: attachment; filename=\"".basename($file)."\"");
readfile($file);

No comments:

Post a Comment