php - Error opening downloaded file from server -
php - Error opening downloaded file from server -
i want user click , download .doc wherever want.. files download when open it, word says: 'missing file c:\users\myname\style.css. click ok , shows me corrupted word document.
php
<?php function download($pathtofile) { header('content-description: file download'); header('content-type: application/force-download'); header('content-transfer-encoding: binary'); header('content-length: '.filesize($pathtofile)); header('content-disposition: attachment; filename="'.basename($pathtofile).'"'); readfile($pathtofile); } if($_server['request_method'] == 'post'){ if(isset($_post['cvcrono'])){ download('../curriculum-vitae-modelo1-azul.doc'); } elseif(isset($_post['cvfun'])){ download('../curriculum-vitae-modelo1b-azul.doc'); } elseif(isset($_post['cvcomb'])){ download('../curriculum-vitae-modelo1c-azul.doc'); } } ?>
html
<tr> <td> <input class='entbutton' type='submit' name='cvcrono' value="descargar"> </td> <td> <input class='entbutton' type='submit' name='cvfun' value="descargar"> </td> <td> <input class='entbutton' type='submit' name='cvcomb' value="descargar"> </td> </tr>
try insert
ob_clean(); ob_flush(); flush();
before
readfile($pathtofile);
php file download server
Comments
Post a Comment