Please help me with my download script
Posted: Tue Sep 13, 2005 12:58 pm
Hello,
I am a newbie in Web programming and I want to make a download script so people could download my file.exe.
Here is the script download.php:
It appears to encounter the following errors:
The errors appear in all line that have header code.
And here is my index.htm:
Anyone please explain me what's wrong with the code and how to solve it
Thanks alot,
I am a newbie in Web programming and I want to make a download script so people could download my file.exe.
Here is the script download.php:
Code: Select all
<?php
$dir="/download/file/";
if (isset($_REQUEST['file'])) {
$file=$dir.$_REQUEST['file'];
header("Content-type: text/plain");
header("Content-Transfer-Encoding: Binary");
header("Content-length: ".filesize($file));
header("Content-disposition: attachment; filename=\"".basename($file)."\"");
readfile("$file");
} else {
echo "No file selected";
}
?>Code: Select all
Warning: Warning: Cannot modify header information - headers already sent by (output started at D:\My Website\download.php:10) in D:\My Website\download.php on line 14And here is my index.htm:
Code: Select all
<html>
<body>
<a href= "../download.php[b]?file=file.exe[/b]" ><font color="#00CC00">Download soft</font></a>
</body>
</html>Thanks alot,