Page 1 of 1
file download script
Posted: Mon Dec 28, 2009 2:16 am
by manojsemwal1
anybody having file download script in php or tutorial i used <a href="
http://path/to/script/download.php?f=ph ... .zip">Cool PHP Tutorial</a> script it works but after download file file has been currepted.............
Re: file download script
Posted: Mon Dec 28, 2009 2:35 am
by mellowman
Can u explain? What you mean by a file download script...like what exactly do you want it to do.?
Re: file download script
Posted: Mon Dec 28, 2009 3:09 am
by pbs
You can use this function
Code: Select all
function force_download($file)
{
$dir = "";
if ((isset($file))&&(file_exists($dir.$file)))
{
header("Content-type: application/force-download");
header('Content-Disposition: inline; filename="' . $dir.$file . '"');
header("Content-Transfer-Encoding: Binary");
header("Content-length: ".filesize($dir.$file));
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="' . $file . '"');
readfile("$dir$file");
}
}
Re: file download script
Posted: Mon Dec 28, 2009 3:56 am
by manojsemwal1
download script means....
i have a site where i want to give a link, through that link the visitor can download the any type of file like doc,zip,pdf etc.
when the visitor click on the link it will ask for save as.
regards,
Re: file download script
Posted: Mon Dec 28, 2009 11:56 pm
by manojsemwal1
The Above function where i have to define the directory path where we kept the file.....
Re: file download script
Posted: Tue Dec 29, 2009 12:07 am
by pbs
Yes
Re: file download script
Posted: Tue Dec 29, 2009 12:14 am
by manojsemwal1
Dear Friend
iam asking where i have to define folder path...............?
Re: file download script
Posted: Tue Dec 29, 2009 12:43 am
by pbs
In function there is $dir variable.