Welcome to WebmasterWorld Guest from 54.226.241.8

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

serving download with php

     

Xuefer

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

10+ Year Member



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

jatar_k

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

WebmasterWorld Administrator jatar_k is a WebmasterWorld Top Contributor of All Time 10+ Year Member



did you get a solution to this Xuefer?

Xuefer

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

10+ Year Member



sorry, not yet

jatar_k

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

WebmasterWorld Administrator jatar_k is a WebmasterWorld Top Contributor of All Time 10+ Year Member



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

Xuefer

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

10+ Year Member



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

hakre

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

WebmasterWorld Senior Member 10+ Year Member



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.

Xuefer

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

10+ Year Member



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 :)

 

Featured Threads

Hot Threads This Week

Hot Threads This Month