Re: Routing downloads through PHP

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



J_K9 wrote:

Well, technically that isn't text output - it's only setting a title... ;)
Technically:
PHP is server sided, so anything that is sended to browser like HTML output is output. Any output in text format sended to the browser (HTML headers and such) will be recognized as normal output.

The header you set with header() is a HTTP header not HTML header.
that's why it wasn't working.

Anyway, I moved the PHP to the top of the file (ie. before the HTML), but now I'm getting a 500 Internal error... Here's the full code I'm using:

Well a 500 error is an internal error so probably your php isnt running as it has to, probably because it is parsed through cgi or such.*shrug*

By the way, you dont have to add the HTML tags.
You just need plain PHP.


----
<?php

header("Pragma: public");
header("Expires: 0"); // set expiration time
header("Cache-Control: must-revalidate, post-check=0,
    pre-check=0");

header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");

$path = "zipdata/downloadme.zip";

header("Content-Disposition: attachment; filename=".$path.";");
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".filesize($path));

readfile($path);

?>
<html>
<head>
<title>Downloads</title>
</head>
<body>
</body>
</html>
----

Any idea what could be going wrong?

Misconfigured server?
What server do you use?
What PHP version?

Barry
--
Smileys rule (cX.x)C --o(^_^o)
Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o)

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux