0

i used file-upload in form in php. i set condition of filetype by file function. but i can't upload .doc and .docx file?? i have added proper MIME type for each though error occur. What should i do?

if($_FILES["return_files"]["name"]!= "")
{
    if ((($_FILES["return_files"]["type"] == "text/plain") || ($_FILES["return_files"]["type"] == "application/pdf") || ($_FILES["return_files"]["type"] == "application/msword") || ($_FILES["return_files"]["type"] == "application/vnd.openxmlformats-officedocument.wordprocessingml.document") && ($_FILES["return_files"]["size"] < 409600))
        {
            ..............
            ..............
        }
}

.txt file and pdf file are uploading but doc and docx file can't upload.

iatboy
  • 1,155
  • 1
  • 10
  • 18
Bhavesh Patel
  • 89
  • 1
  • 1
  • 12
  • For $_FILES["return_files"]["type"] you might be better putting the whitelist inside an array then doing an in_array so shorten your condition params – Oliver Bayes-Shelton Aug 26 '14 at 08:27
  • possible duplicate of [What is a correct mime type for docx, pptx etc?](http://stackoverflow.com/questions/4212861/what-is-a-correct-mime-type-for-docx-pptx-etc) – TunaMaxx Aug 26 '14 at 08:27
  • Also check what is that mime type returned in $_FILES. It may not be the one hardcoded by you for similar files. –  Aug 26 '14 at 08:28

0 Answers0