here is my php code $file = 'csv_coupon_sample.csv'; $path = realpath('../../app/webroot/coupon_forma… echo $src=$path.'/'.$file; if(file_exists($src)) { function ob_clean_all () { $ob_active = ob_get_length ()!== FALSE; while($ob_active) { ob_end_clean(); $ob_active = ob_get_length ()!== FALSE; } return FALSE; } ob_clean_all(); header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: private",false); header("Content-type: application/octet-stream"); header("Content-Disposition: attachment; filename=" . $file . ";" ); header("Content-Transfer-Encoding: binary"); header("Content-Length: ". filesize($src)); readfile($src); exit(); } Is there any thing wrong about the code or it is the server?? every time i go to download the file i get an error like this : "C:\DOCUME~1\dotnet63\LOCALS~1\Temp\Fe… could not be saved, because the source file could not be read. Try again later, or contact the server administrator." Has anyone faced such a problem?? Please help thanks in advance.... Moreover, it's working in one section of my site.
It looks like you simply have the wrong path to the file. It could be because the path you are using is relative to the your php file which is why it might work on some locations and not others depending on the location of the php file. I would suggest using absolute paths to the file if at all possible.