Here is a handy function for forcing a download a file in any folder on the server that is readable by your php script.
PHP:
function send_file($path) {
session_write_close();
ob_end_clean();
if (!is_file($path) || connection_status()!=0)
return(FALSE);
//to prevent long file from getting cut off from //max_execution_time
set_time_limit(0);
$name=basename($path);
//filenames in IE containing dots will screw up the
//filename unless we add this
if (strstr($_SERVER['HTTP_USER_AGENT'], "MSIE"))
$name = preg_replace('/\./', '%2e', $name, substr_count($name, '.') - 1);
//required, or it might try to send the serving //document instead of the file
header("Cache-Control: ");
header("Pragma: ");
header("Content-Type: application/octet-stream");
header("Content-Length: " .(string)(filesize($path)) );
header('Content-Disposition: attachment; filename="'.$name.'"');
header("Content-Transfer-Encoding: binary\n");
if($file = fopen($path, 'rb')){
while( (!feof($file)) && (connection_status()==0) ){
print(fread($file, 1024*8));
flush();
}
fclose($file);
return((connection_status()==0) and !connection_aborted());
https://www.sparkcomputing.co.uk/blogs/htsrv/trackback.php?tb_id=38
No Trackbacks/Pingbacks for this post yet...
Technical articles on IT solutions. Free information on office and home IT solutions; How to get a website running for your business; self-help e-commerce; and tips on website design.
All Words Some Word Entire phrase
Contact Spark • Website Design - Hosting - Ecommerce : Shrewsbury, Shropshire