homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

serving download with php

 9:05 am on Dec 22, 2002 (gmt 0)

i'm using this code:

header("Content-Type: application/octet-stream");
header("Content-Type: application/force-download");
header("Content-Disposition: attachment; filename=$name");
header("Content-Transfer-Encoding: text");

however, when i use this link:

<a href="download.php?id=123" target="_blank">download</a>

in IE:
clicking the link will open a new blank window
if i save it, start&end download, the window will not close

how to solve this peoblem



 7:12 pm on Jan 6, 2003 (gmt 0)

did you get a solution to this Xuefer?


 2:17 am on Jan 7, 2003 (gmt 0)

sorry, not yet


 6:37 pm on Jan 7, 2003 (gmt 0)

what about using javascript on the page to close the window triggered after the download completes?


 1:47 am on Jan 8, 2003 (gmt 0)

how do u know it's completed?
AND when click <a href="ftp://.." target="_blank">download..</a> , the window is closed as soon as download start


 4:56 am on Jan 8, 2003 (gmt 0)

why do you use target="_blank" at all?

if not, a new window won't open.

and why so many headers? i know, there were a lot of problems time ago, but they might all solved now. there is a strict definition in http 1.1 which says that one header is enough:

header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=$name");

the second one is to tell the filename. that's all. it makes no sense to set the Content-Type 2 times. the first one will be overwritten (by php) and that's good.


 5:30 am on Jan 8, 2003 (gmt 0)

cos if i don't use target=_blank, i have to prepare a frame for error message, which may happen to shown up
and i don't want the link to replace current page

it no solution for this topic, then i'll prepare a frame for it :)

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved