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
    Registered User
    Join Date
    Jul 2007
    Posts
    20
    Thanks
    3
    Thanked 0 Times in 0 Posts

    how can i open .txt file using header in php

    i have a link ,whenever i click it will automatically open that file.the file path is saved at $file variable mensioned below.how can i open .txt file using header in php.i tried like
    <?
    $filename = "C:\Documents and Settings\Administrator\Desktop\Hourly Reports\ 237.txt";
    $disp ="content-disposition: attachment;filename='$filename'";
    header('Content-type: text/plain');
    header("Expires: 3");
    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    header($disp);
    ?>
    but it didnt open . can anybody help to open that file.

  • #2
    Regular Coder
    Join Date
    May 2006
    Location
    Wales
    Posts
    820
    Thanks
    1
    Thanked 82 Times in 79 Posts
    Try putting readfile($filename); at the end.


  •  

    Posting Permissions

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