Forum Moderators: coopster
It gives me this error message = Warning: Cannot modify header information - headers already sent by (output started at C:\apache\Apache2\htdocs\JAVASCRIPT\downloadfile.php:4) in C:\apache\Apache2...
SHOWFILES.PHP
<>html>
<head>
<title> Show Files </title>
<?php include("connection.php");?>
</head>
<body bgcolor="#FFFFFF">
<?php
$dbQuery = "SELECT blobId, blobTitle, blobType ";
$dbQuery .= "FROM myBlobs ";
$dbQuery .= "ORDER BY blobTitle ASC";
$result = mysql_query($dbQuery) or die("Couldn't get file list");
?>
<bunch of html output>
</font>
</td><td width="33%" bgcolor="#FFDCA8" height="21">
<p style="margin-left: 10"><font face="Verdana" size="1">
<a href="downloadfile.php?blobId=<?php echo $row["blobId"];?>">
Download now
</a></font>
</td></tr>
<?php
}
echo "</table>";
?>
</body>
</html>
DOWNLOADFILES.PHP
<html>
<head>
<title> Download File </title>
<?php
include("connection.php");
global $blobId;
if(!is_numeric($blobId))
die("Invalid blobId specified");
?>
</head>
<body bgcolor="#FFFFFF">
<?php
$dbQuery = "SELECT blobType, blobData ";
$dbQuery .= "FROM myBlobs ";
$dbQuery .= "WHERE blobId = $blobId";
$result = mysql_query($dbQuery) or die("Couldn't get file list");
if(mysql_num_rows($result) == 1)
{
$fileType = @mysql_result($result, 0, "blobType");
$fileContent = @mysql_result($result, 0, "blobData");
header('Content-Type: ' . $fileType);
echo $fileContent;
}
else
{
echo "Record doesn't exist.";
}
?>
</body>
</html>
THANKS FOR YOUR TIME!
[edited by: jatar_k at 11:33 pm (utc) on April 2, 2004]
[edit reason] reduced code [/edit]
[us2.php.net...]