0

I am using below code for file upload but it do not work in case of doc and excel file

switch(strtolower($ImageType))
        {
            case 'image/png':
            case 'image/gif':   
            case 'application/pdf':
            case 'image/jpeg':
            case 'video/avi':
            case 'video/mp4':
            case 'image/pjpeg':
            case 'application/msword':
            case 'application/vnd.ms-excel':
                break;
            default:
                die('Unsupported File!'); //output error and exit
        }

this code work i case of image but when we upload doc file. it show me unsupported file

Abhik Chakraborty
  • 44,654
  • 6
  • 52
  • 63
Preeti Bisht
  • 69
  • 1
  • 1
  • 9

1 Answers1

1

You are probably missing additional MIME types. Your MIME types are correct for older .doc and .xls files, but not for newer ones.

For .xlsx files use:

application/vnd.openxmlformats-officedocument.spreadsheetml.sheet

For .docx files use:

application/vnd.openxmlformats-officedocument.wordprocessingml.document

This might help you as well:

Community
  • 1
  • 1