Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/80872-solved-downloading-pdfs-from-server/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.