www.webdeveloper.com
Results 1 to 2 of 2

Thread: PHP Validate Uploaded File is PDF

  1. #1
    Join Date
    Dec 2008
    Posts
    130

    PHP Validate Uploaded File is PDF

    How do I check if the uploaded file is pdf with php? I want to validate the file type is pdf and not just the extension matches pdf.


    thanks.

  2. #2
    Join Date
    Dec 2008
    Posts
    130
    Just to clarify. I need to validate 2 files and send them with phpmailer to an email address. Will the below works?

    if(isset($_FILES['upload']['tmp_name'])){
    $finfo = finfo_open(FILEINFO_MIME_TYPE);
    $mime=finfo_file($finfo, $_FILES['upload']['tmp_name']);
    if($mime=='application/pdf'){
    $mail->AddAttachment($mime);
    } } }
    finfo_close($finfo);
    }

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles