Hi,
I have some problems with a script I'm working on. The purpose of the script is to launch a download of a specific file, but the problem is the script won't work and i'm getting these error messages.
I have some problems with a script I'm working on. The purpose of the script is to launch a download of a specific file, but the problem is the script won't work and i'm getting these error messages.
Warning: Cannot modify header information - headers already sent by
Code:
<html>
<head>
<title>Verification</title>
</head>
<body bgcolor="#4B73AA">
<font face="Verdana" size="+1" color="#FFFFFF">
<?php
$word=$_GET['word'];
$from=$_POST['from'];
$subject=$_POST['subject'];
$suggestion=$_POST['suggestion'];
$enter=$_POST['enter'];
if(strcmp ($word, "pass")==0)
{
//The filename is stored in the $produitFilename variable in my script (the only thing you need)
$produitFilename = "Multiple.doc";
// You need to specify the REAL path for your file and not the URL
$fullPath = getcwd()."/download/".$produitFilename;
if ($fd = fopen ($fullPath, "rb")) {
$fsize =filesize($fullPath);
$fname = basename ($fullPath);
header("Pragma: ");
header("Cache-Control: ");
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=\"".$fname."\"");
header("Content-length: $fsize");
fpassthru($fd);
}
}
else
{ echo "Sorry Your password is incorrect <br>";
}
?>
</font>
</body>
</html>