So the code I have used for a button to download a wordpad .rtf file is the following:
My php script:
<?php
if(isset($_POST['file_name'])){
$file = $_POST['file_name'];
header('Content-type: application/rtf');
header('Content-Disposition: attachment; filename="'.$file.'"');
readfile('uploads/'.$file);
exit();
}
and the div associated:
<div class ="buttonhol">
<h2> <center> HOLIDAY REQUEST FORM </center> </h2>
<form action="rota.php" method="post" name="downloadform">
<input name="file_name" value="HolidayRequestForm.rtf" type="hidden">
<input type="submit" value="Download Holiday Request Form">
</div>
-- I have used the exact same code for an excel file in the same folder 'Uploads' however the content-type matches as appropriate. When I click the 'Download Holiday Request Form' button.. the document that gets downloaded is titled correctly however the file just contains all the code written in that particular php class.
What am I doing wrong?
Many thanks in advance.