Try switching out the content-type:
application/x-msexcel
application/ms-excel
application/msexcel
application/x-excel
Try commenting it out too.
header("Content-type: $type") Ignored in Internet
Moderator: General Moderators
-
gerryjuice
- Forum Newbie
- Posts: 12
- Joined: Fri Jan 19, 2007 8:37 am
commenting out has no effect on the current issue.
As far as i know type of the file is picked up by
Changing the application type as suggested before calling makes no difference.
Is there a simpler way to do this, or am i missing something.
Code: Select all
header("Content-type: $type");As far as i know type of the file is picked up by
Code: Select all
$fileType = $_FILES['userfile']['type'];Code: Select all
echo $contentIs there a simpler way to do this, or am i missing something.
-
gerryjuice
- Forum Newbie
- Posts: 12
- Joined: Fri Jan 19, 2007 8:37 am
Put "" around the $name variable in
Which resulted in nothing coming out on the page at all. Does this mean an error occured.
Here is my code currently:
Code: Select all
header("Content-Disposition: attachment; filename=$name");Here is my code currently:
Code: Select all
<!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>
</head>
<body>
<?
if(isset($_GET['id']))
{
include("db.inc.php");
mysql_connect($databaseServer,$user,$passwd) or
die("Could not connect to the database.<br>".mysql_error());
mysql_select_db($database) or
die("Could not select your database.<br>".mysql_error());
$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);
echo $name;
echo $type;
header('Pragma: private');
header('Cache-control: private, must-revalidate');
header('Content-Transfer-Encoding: Binary');
header('Content-Type: application/octet-stream; filename=$name');
header("Content-Disposition: attachment; filename=$name");
//header("Content-length: $size");
//header("Content-type: $type");
echo $content;
//echo ("Content-Disposition: attachment; filename=$name");
//echo ("Content-length: $size");
//echo ("Content-type: $type");
mysql_close();
exit;
}
include("db.inc.php");
mysql_connect($databaseServer,$user,$passwd) or die("Could not connect to the database.<br>".mysql_error());
mysql_select_db($database) or die("Could not select your database.<br>".mysql_error());
$query = "SELECT id, name 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) = mysql_fetch_array($result))
{
?>
<a href="download.php?id=<?=$id;?>"><?=$name;?></a> <br>
<?
}
}
mysql_close();
?>
</body>
</html>- aaronhall
- DevNet Resident
- Posts: 1040
- Joined: Tue Aug 13, 2002 5:10 pm
- Location: Back in Phoenix, missing the microbrews
- Contact:
Code: Select all
<!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>
</head>
<body> Code: Select all
header('Content-Type: application/octet-stream; filename=$name');- daedalus__
- DevNet Resident
- Posts: 1925
- Joined: Thu Feb 09, 2006 4:52 pm