Downloading .txt file problem
Posted: Sun Mar 01, 2009 11:42 pm
Hi friends,
i used this code to download a file php
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 in advance
i used this code to download a file php
Code: Select all
<?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 in advance