I am trying to add accepted file types to a form that was built by someone else. I'm not exactly proficient with PHP.
Can anyone indicate where I am going wrong? I have tried replicating part of the form by adding RTF and TXT file types however the form doesn't appear to accept them still.
Any help is greatly appreciated.
if($_FILES['file']['error'] == UPLOAD_ERR_OK) {
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$mime = finfo_file($finfo, $_FILES['file']['tmp_name']);
if($mime == 'application/msword' || $mime == 'application/pdf' || $mime == 'application/rtf' || $mime == 'text/plain'){
//Check 'temp' Directory Exsists
if(!file_exists(WP_CONTENT_DIR .'/uploads/temp')){
mkdir(WP_CONTENT_DIR .'/uploads/temp', 0777, true);
}
move_uploaded_file($_FILES["file"]["tmp_name"], WP_CONTENT_DIR .'/uploads/temp/'.basename($_FILES['file']['name']));
$attachment = array(WP_CONTENT_DIR ."/uploads/temp/".$_FILES["file"]["name"]);
} else {
$validation_message = "<span class='error'><i class='icon-remove-sign'></i> Invalid File Type</span>";
$attachment = NULL;
$passes = false;
}
} else {
$attachment = NULL;
}
You may check by getting the output of variable
$mime
. You can also put the type in superglobal array$_FILES
.