I'm using PHP to upload a file, but I would like to allow only PDF,DOC,DOCX. I found some answers here but none of them helped me.
Thats my code:
$from = str_replace(array("\r", "\n"), '', $mail); // to prevent email injection
if ($file) {
$filename = basename($_FILES['fileupload']['name']);
$file_size = filesize($file);
$content = chunk_split(base64_encode(file_get_contents($file)));
$uid = md5(uniqid(time()));
$header = "MIME-Version: 1.0\r\n"
."From: {$name}<{$from}>\r\n"
."Content-Type: multipart/mixed; boundary=\"".$uid."\"\r\n\r\n"
."This is a Mime.\r\n\r\n"
."--".$uid."\r\n"
."From: {$name}<{$from}>\r\n"
."Content-type:text/html; charset=UTF-8\r\n\r\n"
.$msg1."\r\n\r\n"
."--".$uid."\r\n"
."Content-Type: application/octet-stream; name=\"".$filename."\"\r\n"
."Content-Transfer-Encoding: base64\r\n"
."Content-Disposition: attachment; filename=\"".$filename."\"\r\n\r\n"
.$content."\r\n\r\n"
."--".$uid."--";
$msg1 = '';
} else {
$header = "MIME-Version: 1.0\r\n";
$header .= "Content-type: text/html; charset=UTF-8\r\n";
$header .= "From: <".$mail. ">" ;
}