I cannot understand this, and I know that it is simple. I am creating a back-end for a very simple content management system. For this particular part, I'm just trying to create a PHP link that allows you to upload a file (client CV).
MY PROBLEM:
When you click the link to download the file instead of the browser prompting you to select the local directory for saving the file, it simply displays the file and a bunch of characters before and after the contents of the document (I assume this is opening and closing exif files for the decryption application).
How can I get the browser to ask the user "Save as ..."?
<?php require("connect.php"); $query = "SELECT * FROM kb_info LIMIT 1"; $result = mysql_query($query, $link); while ($row = mysql_fetch_array($result)) { $file_extension = end(explode(".", $row["extension"])); if ($file_extension == doc) { header('Content-disposition: attachment; filename='.$row["extension"]); header('Content-type: application/doc'); header ("Content-Length: ".filesize($row["extension"])); readfile($row["extension"]); exit; } if ($file_extension == docx) { header('Content-disposition: attachment; filename='.$row["extension"]); header('Content-type: application/docx'); header ("Content-Length: ".filesize($row["extension"])); readfile($row["extension"]); exit; } if ($file_extension == pdf) { header('Content-disposition: attachment; filename='.$row["extension"]); header('Content-type: application/pdf'); header ("Content-Length: ".filesize($row["extension"])); readfile($row["extension"]); exit; } } ?>
Many thanks,
Joshi
php download content-management-system
j0sh1e
source share