😕
Hello All,
I already made a file manager. Where session based registered member can manage their files and folder. I want to add a download section in this. Means when any user click on download hyper link the file must start downloading.
I am using following code for this download :
<?
include ("../../main.php");
if(checkses() == false){
header("Location: ../../login.php");
exit();
}
list($u_name,$t_id) = split("+",$ses_var);
$path="<path where all user folder exists >".$u_name;
$fullpath=stripslashes($path.$FileName);
header("Cache-control: private");
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename='$fullpath'");
header("Content-transfer-encoding: binary");
readfile($fullpath);
?>
- $u_name – Name of the user.
$path -- Path where file exists.
$FileName – Name of the file to be download
When I use :
Name : download.php
<?
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=$FileName");
header("Content-transfer-encoding: binary");
readfile($FileName);
?>
and Put this download.php file in same folder where all files exists then it works, only problem is browser get hanged some times.
But when I pass full path it will not work properly always try to download with then same script file name (download)
Thanks in advance