Sunday, 15 April 2012

php - Alternative way to hide download link -



php - Alternative way to hide download link -

i'm using code hide download link giving uncompleted download users. don't know why, many users study problem me. current code is:

file = "../".$realfilename; $fakefilename= 'upbaz.ir-'.base64_decode($_get['ffname']); $fp = fopen($file, 'rb'); header("content-type: application/octet-stream"); header("content-disposition: attachment; filename=$fakefilename"); header("content-length: " . filesize($file)); fpassthru($fp);

anyone know other way hide download link?

this script handle downloading of file , includes buffer/ different ext types (if desire). way hide links set files in protected directory , have links stored in database. user sees id or session tied file , server finds file , serves it.

if ($fd = fopen ($fullpath, "r")) { $fsize = filesize($fullpath); $path_parts = pathinfo($fullpath); $ext = strtolower($path_parts["extension"]); switch ($ext) { case "txt": header("content-type: application/txt"); // add together here more headers diff. extensions header("content-disposition: attachment; filename=\"".$path_parts["basename"]."\""); // utilize 'attachment' forcefulness download break; default: header("content-type: application/octet-stream"); header("content-disposition: attachment; filename=\"".$path_parts["basename"]."\""); } header("content-length: $fsize"); header("cache-control: private"); //use open files straight while(!feof($fd)) { $buffer = fread($fd, 2048); echo $buffer; } } fclose ($fd);

.htaccess protect directory (you should have dir these files

deny

above script modified yours:

$file = "../".$realfilename; $fakefilename= 'upbaz.ir-'.base64_decode($_get['ffname']); if ($fd = fopen ($file, "r")) { $fsize = filesize($file); header("content-type: application/octet-stream"); header("content-disposition: attachment; filename=\"$fakename\""); header("content-length: $fsize"); header("cache-control: private"); //use open files straight while(!feof($fd)) { $buffer = fread($fd, 2048); echo $buffer; } } fclose ($fd);

php html upload download

No comments:

Post a Comment