I know about the header "somthing.zip" thing, but I also know that you should specify stuff like file type etc. how ddo this, also, can you make the browser download a html or jpg file. I don't mean load it in the browser but download it.
Printable View
I know about the header "somthing.zip" thing, but I also know that you should specify stuff like file type etc. how ddo this, also, can you make the browser download a html or jpg file. I don't mean load it in the browser but download it.
You may find this useful: http://www.vbforums.com/showthread.p...hreadid=280492
that's perfect thanks. I did do a search, but didn't find that
This code works for getting .zip files, but when I try Dloading a .html file, it simply loads it.
this is the code for the button which is clicked:PHP Code:<?
//Download a file
$file = $_GET['file'];
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
header("Content-type: application/x-zip");
header("Content-disposition: inline; filename=".$file);
header('Location: '.$file);
?>
This code works, as I use it later with a .zip file, and that works fine. I doubt it's the button which is at fault.PHP Code:print "<input type='button' value='Run script' onClick=location.href='/download.php?file=/JavaScript/".$pre.$a.".html'>";
If you set the contenttype to plain text, I think it'll d/l the html, rather than display it..... ????
TG
tried "text" and "plain text", neither worked.
what if you append .txt to the end of the file name????
TG
Make this change:This is meant to make IE download the file no matter what, I can't be too sure what happens in other browsers.om reading the comments at: http://us2.php.net/manual/en/function.header.php ;).PHP Code:// Change this...
header("Content-disposition: inline; filename=".$file);
// To...
header("Content-disposition: attachment; filename=".$file);
no change, not in IE or FX.Quote:
Originally posted by Electroman
Make this change:This is meant to make IE download the file no matter what, I can't be too sure what happens in other browsers.om reading the comments at: http://us2.php.net/manual/en/function.header.php ;).PHP Code:// Change this...
header("Content-disposition: inline; filename=".$file);
// To...
header("Content-disposition: attachment; filename=".$file);
try this
PHP Code:<?
//Download a file
$file = $_GET['file'];
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
header("Content-type: application/x-zip");
header("Content-disposition: attachment; filename=".$file);
readfile($file);
?>
that worked ;)
but it seemed to insert dashed before and after $pre. I'm not bothered though, thanks.