How can a PDF document with a PHP-triggering button be uploaded to a server or sent via email?

To upload a PDF document with a PHP-triggering button to a server or send it via email, you can use a form with a file input field for uploading the PDF and a submit button to trigger the PHP script handling the upload or email sending. In the PHP script, you can use the $_FILES superglobal to access the uploaded file and move it to a designated folder on the server. If you want to send the PDF via email, you can use the PHPMailer library to attach the uploaded PDF to the email.

<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    if (isset($_FILES['pdf_file'])) {
        $pdf_name = $_FILES['pdf_file']['name'];
        $pdf_tmp = $_FILES['pdf_file']['tmp_name'];
        
        // Move the uploaded PDF to a folder on the server
        move_uploaded_file($pdf_tmp, 'uploads/' . $pdf_name);
        
        // If you want to send the PDF via email using PHPMailer
        // Add PHPMailer code here
    }
}
?>

<form method="post" enctype="multipart/form-data">
    <input type="file" name="pdf_file">
    <button type="submit">Upload PDF</button>
</form>