Force File Download

Posted on Saturday, July 25, 2009 in PHP

header('Content-Description: File Transfer');
header('Content-Type: application/force-download');
header('Content-Length: ' . filesize("$fname"));
header('Content-Disposition: attachment; filename=' . $fname);
set_time_limit(0);
readfile("$fname");
exit();

Max Execution and Mem Limit

Posted on Saturday, June 27, 2009 in PHP

ini_set('max_execution_time', 2000);
ini_set('memory_limit', '700M');

Find File Extension

Posted on Friday, June 19, 2009 in PHP

$ext=strtolower(substr(strrchr($file,"."),1));

Remove Whitespaces and Tabs

Posted on Wednesday, June 3, 2009 in PHP

function clean($dat=0) {
if(!$dat) { return; }
$dat=preg_replace("/[\r\n\s\t]+/", "", $dat);
return($dat);
} // clean