Hello I'm doing my project and i want to ask just a simple question. Every time I go to that page it downloads automatically without getting inside on that page. When I click the button it automatically download the files. But I want to go that page and click a link before downloading it. Anyone help?
if(isset($_GET['profile']))
{
$id=$_GET['profile'];
$query = "SELECT * FROM profile_table WHERE id=?";
$stmt=$con->prepare($query);
$stmt->bind_param("i",$id);
$rc = $stmt->execute();
if ( false===$rc ) {
die('execute() failed: ' . htmlspecialchars($stmt->error));
}
$result = $stmt->get_result();
$row = $result->fetch_assoc();
$vid = $row['id'];
$vfname = $row['fname'];
$vlname = $row['lname'];
$vmname = $row['mname'];
$vsex = $row['sex'];
$vage = $row['age'];
$vbday = $row['bday'];
$vbloodtype = $row['bloodtype'];
$vheight = $row['height'];
$vweight = $row['weight'];
$vreligion = $row['religion'];
$vcolorhair = $row['colorhair'];
$vdistmark = $row['distmark'];
$vmobile = $row['mobile'];
$vtin = $row['tin'];
$vphealth = $row['phealth'];
$vlegaldep = $row['legaldep'];
$vaddress = $row['address'];
$vtsize = $row['tsize'];
$vheadgear = $row['headgear'];
$vshoes = $row['shoes'];
$vuniform = $row['uniform'];
$vphoto = $row['photo'];
$vsoi = $row['soi'];
if (file_exists($vsoi)) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename=' . basename($vsoi));
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize('documents/' . $row['name']));
readfile('documents/' . $row['name']);
}
}
I think the problem their is the file_exist in vsoi. And I dont know what to do or to change in my code. I appreciate all the answers. TIA!