|
-
Apr 21st, 2004, 03:34 PM
#1
Thread Starter
Frenzied Member
Downloading files [resolved]
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.
Last edited by Acidic; Apr 21st, 2004 at 05:25 PM.
Have I helped you? Please Rate my posts. 
-
Apr 21st, 2004, 03:44 PM
#2
Ex-Super Mod'rater
When your thread has been resolved please edit the original post in the thread (  )
and amend "-[RESOLVED]-" to the end of the title and change the icon to  , Thank you.
When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

-
Apr 21st, 2004, 04:25 PM
#3
Thread Starter
Frenzied Member
that's perfect thanks. I did do a search, but didn't find that
Have I helped you? Please Rate my posts. 
-
Apr 21st, 2004, 04:43 PM
#4
Thread Starter
Frenzied Member
This code works for getting .zip files, but when I try Dloading a .html file, it simply loads it.
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 is the code for the button which is clicked:
PHP Code:
print "<input type='button' value='Run script' onClick=location.href='/download.php?file=/JavaScript/".$pre.$a.".html'>";
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.
Have I helped you? Please Rate my posts. 
-
Apr 21st, 2004, 04:57 PM
#5
If you set the contenttype to plain text, I think it'll d/l the html, rather than display it..... ????
TG
-
Apr 21st, 2004, 04:59 PM
#6
Thread Starter
Frenzied Member
tried "text" and "plain text", neither worked.
Have I helped you? Please Rate my posts. 
-
Apr 21st, 2004, 05:03 PM
#7
what if you append .txt to the end of the file name????
TG
-
Apr 21st, 2004, 05:08 PM
#8
Ex-Super Mod'rater
Make this change:
PHP Code:
// Change this...
header("Content-disposition: inline; filename=".$file);
// To...
header("Content-disposition: attachment; filename=".$file);
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 .
When your thread has been resolved please edit the original post in the thread (  )
and amend "-[RESOLVED]-" to the end of the title and change the icon to  , Thank you.
When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

-
Apr 21st, 2004, 05:11 PM
#9
Thread Starter
Frenzied Member
Originally posted by Electroman
Make this change:
PHP Code:
// Change this...
header("Content-disposition: inline; filename=".$file);
// To...
header("Content-disposition: attachment; filename=".$file);
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 .
no change, not in IE or FX.
Have I helped you? Please Rate my posts. 
-
Apr 21st, 2004, 05:20 PM
#10
<?="Moderator"?>
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);
?>
-
Apr 21st, 2004, 05:25 PM
#11
Thread Starter
Frenzied Member
that worked 
but it seemed to insert dashed before and after $pre. I'm not bothered though, thanks.
Have I helped you? Please Rate my posts. 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|