I created a profile page to view members info's one of the information is his/her cv. I Could manage viewing a window that have an open or download options BUT I have two problems:
1- in Chrome open option dose not appear I have download option only.
2- I cant open nor download the cv in both chrome and Firefox, the file name appear with the server name in the open or save window.
Here is my code: PHP:
if(isset($_GET['cv']))
{
$id = $_GET['cv'];
$query = "SELECT `fileName`, `fileType`, `fileSize`, `fileContent` FROM `boardteam` WHERE `nationalID` = '$id'";
$r = mysql_query($query) or die('Error, query failed');
list($fname, $ftype, $fsize, $fcontent) = mysql_fetch_array($r);
header('Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document');
header("Content-Disposition: attachment; filename=$fname");
header('Content-Length: ' . filesize($fsize));
ob_clean();
flush();
readfile($fname);
exit;
}
HTML:
<a href='browseMember.php?cv=<?php echo $member_id?>'>
<?php
$q = "SELECT `fileName`, `fileType`, `fileSize`, `fileContent` FROM `boardteam` WHERE `nationalID` = '$member_id'";
$r = mysql_query($q) or die('Error, query failed');
list($fname, $ftype, $fsize, $fcontent) = mysql_fetch_array($r);
if ($fname)
{
echo "click here to open member CV";
}
?>
</a>
UPDATE:
Lets assume cv file type is docx, If it works I will switch to case doc and pdf and change content type.