|
Posted by NC on 05/05/06 21:11
vamichael@gmail.com wrote:
>
> I'm using the following to try and send a file to user, however instead
> of getting a "save as" dialog box I'm getting ascii garbage (presumably
> the contents of the file) in the browser instead. Can someone please
> help? I need the solution to work in both Firefox and IE. Thanks!
>
> <?php
> $url="myfile.exe";
> header("Content-type: application/octet-stream");
> header("Content-Disposition: inline; filename=".basename($url)."");
> readfile($url);
> ?>
OK... There's an ugly hack that actually works...
First of all, change the URL you use to refer to your script. Right
now, you have something like this:
http://www.example.com/path/download.php
Replace it with:
http://www.example.com/path/download.php/myfile.exe
Then, you can rewrite your download.php as follows:
<?php
$url = 'myfile.exe';
header('Content-Type: application/octet-stream');
header("Content-Disposition: attachment; filename=$url");
readfile($url);
?>
Cheers,
NC
Navigation:
[Reply to this message]
|