hey guys is this coding is write for downloading purpose.
this gives me a file from database but it doesn't shows the file content in it.there is an error which shows in my file
<br />
<b>Warning</b>: readfile(..\wam p\www\New folder\download file\New folderSushant_N aik.doc) [<a href='function. readfile'>funct ion.readfile</a>]: failed to open stream: No such file or directory in <b>C:\wamp\www\ New folder\download file\download1. php</b> on line <b>48</b><br />
this gives me a file from database but it doesn't shows the file content in it.there is an error which shows in my file
<br />
<b>Warning</b>: readfile(..\wam p\www\New folder\download file\New folderSushant_N aik.doc) [<a href='function. readfile'>funct ion.readfile</a>]: failed to open stream: No such file or directory in <b>C:\wamp\www\ New folder\download file\download1. php</b> on line <b>48</b><br />
Code:
<?php include('config.php'); $filename=$_GET['fname']; $ctype=$_GET['ctype']; $size=$_GET['size']; /* echo $filename; echo $ctype; echo $size; */ $tmp = explode(".",$filename); switch ($tmp[count($tmp)-1]) { case "pdf": $ctype="application/pdf"; break; case "exe": $ctype="application/octet-stream"; break; case "zip": $ctype="application/zip"; break; case "docx": case "doc": $ctype="application/msword"; break; case "csv": case "xls": case "xlsx": $ctype="application/vnd.ms-excel"; break; case "ppt": $ctype="application/vnd.ms-powerpoint"; break; case "gif": $ctype="image/gif"; break; case "png": $ctype="image/png"; break; case "jpeg": case "jpg": $ctype="image/jpg"; break; case "tif": case "tiff": $ctype="image/tiff"; break; case "psd": $ctype="image/psd"; break; case "bmp": $ctype="image/bmp"; break; case "ico": $ctype="image/vnd.microsoft.icon"; break; default: $ctype="application/force-download"; } $path=$filename; header("Pragma: public"); // required header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: private",false); // required for certain browsers header("Content-Type: $ctype"); header("Content-Disposition: attachment; filename=\"$path\""); header("Content-Transfer-Encoding: binary"); header("Content-Length: ".$size); echo $path; ob_clean(); flush(); readfile($path) ?>
Comment