Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jan 2006
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to redirect url after file download.

    Hi,

    I want to redirect url after file download, now I have the following script:
    PHP Code:
    <?
    include("refcode.php");

    if(
    false!=file_exists("./up/".$ups[$_POST['code']]))
    {
      
    $file_dir "./updir/";
      
    $myFileName=$ups[$_POST['code']];
        
      
    $file fopen($file_dir.$myFileName,"r");
      if (!
    $file
      {
        
    show_msg("File not open.");
      } 
      else 
      {
        
    Header("Content-type: application/octet-stream");
        
    Header("Content-Disposition: attachment; filename=" $myFileName);
        while (!
    feof ($file)) 
        {
          echo 
    fread($file,50000);
        }
        
    fclose ($file);
        
    show_msg("Download sucessfully.");
      }
    }
    else
    {
        
    show_msg("File not existed.");
    }

    function 
    show_msg($msg)
    {
        include(
    "error.php");
        exit();
    }
    ?>
    The file "error.php" is used to display some information about download.The function show_msg is responsible for display the message in a new page.

    Now the file can be downloaded sucessfully, but the problem is that show_msg does not execute after file download.

    I think it may be caused by "Header", but I'm not sure.

    Can anyone help me to figure it out?

    Thanks.
    Last edited by firepages; 01-12-2006 at 07:14 AM.

  • #2
    Senior Coder
    Join Date
    Apr 2005
    Posts
    1,051
    Thanks
    0
    Thanked 0 Times in 0 Posts
    is it not entering the function?
    can you put die("function entered"); right after the start of the function to see?

    i don't see setting header output stopping the function from being called.

    when all this happens check the source to see if it's a php error. sometimes they don't show up on the page. :S
    public string ConjunctionJunction(string words, string phrases, string clauses)
    {
    return (String)(words + phrases + clauses);
    }
    <--- Was I Helpfull? Let me know ---<


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •