misslois74
Programmer
im currently working on a site wherein on the backend the administrator would be able to force download the file that has been attached by a user in the front end i cant seem to figure it out since whats happening right now is the browser is loading the file, special characters are appearing on the page....
here is my sample code:
the part which calls this is the ff:
echo "<tr>
<td class=Arial11Grey><input type='checkbox' name='id2[]' value='$id'><a href=$PHP_SELF?op=download&id=$id&filename=$fname><u>$fname</u></a></td>
<!--<td class=Arial11Grey><input type='checkbox' name='id2[]' value='$id'><a href=$PHP_SELF?op=download&id=$id><u>$fname</u></a></td>-->
<td class=Arial11Grey>".nice_size($size)."</td>
<!--<td class=Arial11Grey>".str_replace(',','<br>',$tags)."</td>-->
<td class=Arial11Grey>$type</td>
<td class=Arial11Grey>$added</td>
<td class=Arial11Grey>$employer</td>";
thanks in advance
here is my sample code:
Code:
if($op=='download') {
list($fpath,$filename,$file)=sqlget("
select filepath,filename,file from employer_sent_files
where file_id='$id'");
$file = $_GET['filename'];
header('Cache-Control: private');
header('Pragma: private');
header("Content-Transfer-Encoding: binary") ;
header("Content-Disposition: attachment; filename=\"" . basename($file) . "\"");
header("Content-Length:" . filesize($file));
header("Content-Type: application/application/octet-stream;");
readfile($file);
}
the part which calls this is the ff:
echo "<tr>
<td class=Arial11Grey><input type='checkbox' name='id2[]' value='$id'><a href=$PHP_SELF?op=download&id=$id&filename=$fname><u>$fname</u></a></td>
<!--<td class=Arial11Grey><input type='checkbox' name='id2[]' value='$id'><a href=$PHP_SELF?op=download&id=$id><u>$fname</u></a></td>-->
<td class=Arial11Grey>".nice_size($size)."</td>
<!--<td class=Arial11Grey>".str_replace(',','<br>',$tags)."</td>-->
<td class=Arial11Grey>$type</td>
<td class=Arial11Grey>$added</td>
<td class=Arial11Grey>$employer</td>";
thanks in advance