Jump to content

Force download issue


CanMan2004

Recommended Posts

Hi all

I have the following script which forces a file download

[code]    $dir="../../documents/";
    $getfile=$dir.$filename;
    header("Content-type: application/force-download");
    header("Content-Transfer-Encoding: Binary");
    header("Content-length: ".filesize($getfile));
    header("Content-disposition: attachment; filename=\"".basename($getfile)."\"");
    readfile("$getfile");[/code]

The problem is that if I run this, there is no way to perform a close window script or a page redirection script when the file download box has poped up, the reason I ask is that when you excuite the above code, you areu are left with a blank page.

Does that make sense?

Thanks in advance

Ed
Link to comment
Share on other sites

Normally this would be called as a link from another page using the standard <a href......... etc.  If you're doing this, you should be able to use target="_self" as an attribute of the link.  This will open the download file box in the same window without moving on or opening a new blank window.  Let me know if this doesn't work and I'll double check but I'm fairly certain that's the way around it.

Dest
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.