Hi,
I have got the upload working, but if I want to retrieve the file, it is corrputed. Only txt files are readable. A gif/jpeg/doc file is not readable!
Help me.
What is wrong here?, here is my down.php script:
<?php
if (!isset($submit))
{
?>
<html>
<body>
<FORM ENCTYPE="multipart/form-data" action="<? echo $PHP_SELF;?>" method=POST>
<INPUT TYPE="text" size="10" name="id" >
<INPUT TYPE="submit" name="submit" VALUE="Send File">
<font size=-1><a href=up.php>Klick for upload</a>.</font>
</FORM>
</body>
</html>
<?
}
else
{
// includes
include("../conf.php");
include("../functions.php");
$errorList = array();
$count = 0;
// open database connection
$connection = mysql_connect($host, $user, $pass) or die ("Unable to
connect!");
// select database
mysql_select_db("test") or die ("Unable to select database!");
// generate and execute query
$query = "select mime, best, name from files where id = $id";
$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
// print result
$data = @ mysql_fetch_array($result);
//while($row = mysql_fetch_object($result))
//{
if (!empty($data["best"]))
{
//header("Content-type:echo $data["best"];");
header("Content-Type: {$data["mime"]}");
header("Content-Disposition: attachment; filename={$data["name"]}");
//header("Content-type: image/gif");
echo $data["best"];
}
//echo $row->mime;
//echo $row->best;
//}
//echo "<font size=-1>read successful. <a href=down.php>Go back to the main menu</a>.</font>";
// close database connection
mysql_close($connection);
}
?>
if I disable output_buffering it fails completely.