SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Mar 2009
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy Downoading .txt file code error

    Hi friends,

    i used this code to download a file php

    PHP Code:
    <?php
    if(isset($_GET['uploadid']))
    {
    // if id is set then get the file with the id from database
     
    $upid $_GET['uploadid'];
    $recruid $_GET['userid']; 
    $resFile $admin->getRecruiteruploadDetailsByUploadid($upid);
    $rowFile mysql_fetch_array($resFile);
    $filename $rowFile['File_Path'];
    $downloadFile "../".$uploadsfolder."employeruploads/" $recruid ."/".basename($filename); 
    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    header('Content-type: application');
    header('Content-Disposition: attachment; filename=' basename($filename) . ';');
    $contentData file_get_contents($downloadFile);
    readfile($downloadFile);
    }
     
    ?>

    it is working fine for all extensions like .doc,.pdf,.xls,.gif etc
    but when i download .txt file it is downloading the txt file with some extra code. The extra code is nothing but the php file where i wrote the above code.

    what is the problem?
    can anyone give me the solution please............

    Thanks

  2. #2
    SitePoint Addict
    Join Date
    Dec 2007
    Posts
    358
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are you sure that the downloaded txt file does not contain this code snippet?
    I'm creating trouble-free Apache, PHP, MySQL installer, WITSuite,
    and use it to setup my development environment.
    Demo, support, contact. Questions?

  3. #3
    SitePoint Member
    Join Date
    Mar 2009
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i got it. i placed exit; after readfile() statement.
    it is working fine now
    Thanq


Bookmarks

Posting Permissions

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