graham23s Posted December 9, 2007 Share Posted December 9, 2007 Hi Guys, i have a button on a form that when clicked should download the users .pdf document that they have uploaded but, when i click it, all i get is .txt file with a warning in it button: <form action=\"downloadcv.php?id=$recipientsid\" method=\"post\"><input type=\"hidden\" name=\"hiddenusersid\" value=\"$recipientsid\"><input type=\"submit\" class=\"btn\" value=\"Download My CV\"></form> code: <?php ## the includes include("includes/sessions.php"); include("includes/db_connection.php"); include("includes/constants.php"); ?> <?php ################################################# # downloadcv.php ################################################# $usersid = mysql_real_escape_string($_POST['hiddenusersid']); ## query the cv db $qcv = "SELECT * FROM `userscvs` WHERE `userid`='$usersid' LIMIT 1"; $rcv = mysql_query($qvc); $row = mysql_fetch_array($rcv); ## vars $cvid = $row['id']; $cvuserid = $row['userid']; $cvname = $row['cvname']; ## headers header("Pragma: public"); header("Expires: 0"); header("Content-Type: application/force-download"); header("Content-Type: application/pdf"); header("Content-Disposition: attachment; filename=\"$cvname\""); @readfile("cvs/$cvname"); ?> i pass the users id through, check it against the "userscv" table then grab the variables and then it should download, is there anything i have missed here? thanks guys Graham Quote Link to comment https://forums.phpfreaks.com/topic/80872-solved-downloading-pdfs-from-server/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.