Hello all, I'm back after a 'long' and much needed break. My issue (if anyone can help) is uploading any .doc file or .pdf file, restricting the ability to upload any other file format:
This Works to upload only .doc files:
foreach($_FILES as $file_name => $file_array) {
if ($file_array['type'] != "application/msword") {
echo "error<br>" . $file_array['error'];
} else {
if (is_uploaded_file($file_array['tmp_name'])) {
move_uploaded_file($file_array['tmp_name'], "uploads/$file_array[name]") or die ("Couldn’t copy");
echo "success";
}//close if
}//close else
}//close foreach
This Doesn't work as it wont allow .doc OR .pdf:
foreach($_FILES as $file_name => $file_array) {
if (($file_array['type'] != "application/msword" || ($file_array['type'] != "application/pdf")) {
echo "error<br>" . $file_array['error'];
} else {
if (is_uploaded_file($file_array['tmp_name'])) {
move_uploaded_file($file_array['tmp_name'], "uploads/$file_array[name]") or die ("Couldn’t copy");
echo "success";
}//close if
}//close else
}//close foreach
Doing it the new way to check to see if both a .doc file or .pdf file was uploaded returns the error instead of the success echo? Anyone know why? and while we are at this hows my 'gulp' security?
The below allows ANY file type to be uploaded :queasy:
if ($file_array['type'] != ("application/msword" || "application/pdf")) {
Thank you for any help anyone maybe able to provide. And yes, I've already been to w3schools php section with no help.