[SOLVED] Force download files
Moderator: General Moderators
-
tristanlee85
- Forum Contributor
- Posts: 172
- Joined: Fri Dec 19, 2003 7:28 am
[SOLVED] Force download files
I've created a downloads section on my forum and the files that are being downloaded are.msq files. Right now, if a user clicks the link to download the file, it opens the file as a text file within the browser. Can I use header() to force the file to b downloaded?
Last edited by tristanlee85 on Thu Sep 28, 2006 1:06 am, edited 3 times in total.
-
tristanlee85
- Forum Contributor
- Posts: 172
- Joined: Fri Dec 19, 2003 7:28 am
Nevermind. I just had to comment something out.
Doesn't work
Does work
Doesn't work
Code: Select all
if (isset($_GET['download']))
{
$filename = $_GET['download'];
header("Content-Type: ".get_mimetype($filename));
header("Content-Length: ".filesize($path . $filename));
header("Content-Disposition: attachment; filename=$filename");
readfile($path . $filename);
}Code: Select all
if (isset($_GET['download']))
{
$filename = $_GET['download'];
header("Content-Length: ".filesize($path . $filename));
header("Content-Disposition: attachment; filename=$filename");
readfile($path . $filename);
}-
tristanlee85
- Forum Contributor
- Posts: 172
- Joined: Fri Dec 19, 2003 7:28 am
-
tristanlee85
- Forum Contributor
- Posts: 172
- Joined: Fri Dec 19, 2003 7:28 am