scorpken
Legacy Member
Warning: Cannot modify header information - headers already sent by (output started at /opt/www/sam/htdocs/downloadtest.php:2) in /opt/www/sam/htdocs/downloadtest.php on line 14
Warning: Cannot modify header information - headers already sent by (output started at /opt/www/sam/htdocs/downloadtest.php:2) in /opt/www/sam/htdocs/downloadtest.php on line 15
Warning: Cannot modify header information - headers already sent by (output started at /opt/www/sam/htdocs/downloadtest.php:2) in /opt/www/sam/htdocs/downloadtest.php on line 16
Tot nu werkte het altijd, zou niet weten wat ik in de code heb aangepast!
downloadtest:
Downloadspub(pagina zelf)
Warning: Cannot modify header information - headers already sent by (output started at /opt/www/sam/htdocs/downloadtest.php:2) in /opt/www/sam/htdocs/downloadtest.php on line 15
Warning: Cannot modify header information - headers already sent by (output started at /opt/www/sam/htdocs/downloadtest.php:2) in /opt/www/sam/htdocs/downloadtest.php on line 16
Tot nu werkte het altijd, zou niet weten wat ik in de code heb aangepast!
downloadtest:
PHP:
<?
if(isset($_GET['id']))
{
mysql_connect("localhost", "sam", "sam");
mysql_select_db("cms") or die(mysql_errno() . ": " . mysql_error() . "<br />");
$id = $_GET['id'];
$query = "SELECT name, type, size, content FROM upload WHERE id = '$id'";
$result = mysql_query($query) or die('Error, query failed');
list($name, $type, $size, $content) = mysql_fetch_array($result);
header("Content-Disposition: attachment; filename=$name");
header("Content-length: $size");
header("Content-type: $type");
echo $content;
exit;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Download File From MySQL</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<?
mysql_connect("localhost", "sam", "sam");
mysql_select_db("cms") or die(mysql_errno() . ": " . mysql_error() . "<br />");
$query = "SELECT id, name, size, type, user,beschrijving FROM upload";
$result = mysql_query($query) or die('Error, query failed');
if(mysql_num_rows($result) == 0)
{
echo "Database is empty <br />";
}
else
{
while(list($id, $name, $fileSize, $fileType,$user,$beschrijving) = mysql_fetch_array($result))
{
?>
<b>Bestand:</b> <a href="http://michael.rekencentra.be/downloads/<?=$name;?>"><?=$name;?></a> <a src="downloadtest.php?id=<?=$filesSize;?>"><?=$fileSize;?></a><b>B</b> <br />
<b>Bestand voor:</b> <a src="downloadtest.php?user=<?=$user;?>"><?=$user;?></a> <br />
<b>Beschrijving :</b> <a src="downloadtest.php?beschrijving=<?=$beschrijving;?>"><?=$beschrijving;?></a> <br />
<?
}
}
?>
</body>
</html>
Downloadspub(pagina zelf)
PHP:
<?
if(isset($_GET['id']))
{
mysql_connect("localhost", "sam", "sam");
mysql_select_db("cms") or die(mysql_errno() . ": " . mysql_error() . "<br />");
$id = $_GET['id'];
$query = "SELECT name, type, size, content FROM upload WHERE id = '$id'";
$result = mysql_query($query) or die('Error, query failed');
list($name, $type, $size, $content) = mysql_fetch_array($result);
header("Content-Disposition: attachment; filename=$name");
header("Content-length: $size");
header("Content-type: $type");
echo $content;
exit;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Download File From MySQL</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<?
mysql_connect("localhost", "sam", "sam");
mysql_select_db("cms") or die(mysql_errno() . ": " . mysql_error() . "<br />");
$query = "SELECT id, name, size, type, user,beschrijving FROM upload where user='publiek'";
$result = mysql_query($query) or die('Error, query failed');
if(mysql_num_rows($result) == 0)
{
echo "Database is empty <br />";
}
else
{
while(list($id, $name, $fileSize, $fileType,$user,$beschrijving) = mysql_fetch_array($result))
{
?>
<table width="550" border="0">
<tr>
</tr>
<tr>
<th width="100" scope="col">
<?
if($fileType == "image/jpeg"){
echo("<img height='80' width='80' src='http://michael.rekencentra.be/downloads/$name'><?=$name;?>>");
}else{
echo("Geen voorbeeld beschikbaar!");
}
?>
</th>
<th width="450" scope="col">
<b>Bestand:</b> <a href="downloadtest.php?id=<?=$id;?>"><?=$name;?></a> <a src="downloadtest.php?id=<?=$filesSize;?>"><?=$fileSize;?></a><b>Kb</b> <br />
<font size="2"><b>Bestand voor:</b> <a src="downloadtest.php?user=<?=$user;?>"><?=$user;?></a> <br />
<b>Beschrijving :</b> <a src="downloadtest.php?beschrijving=<?=$beschrijving;?>"><?=$beschrijving;?></a> <br /><br /><br /></font>
</th>
<br />
</tr>
</table>
<br />
<?
}
}
?>
</body>
</html>
