S
S
Svyatoslav Nemato2016-09-03 21:38:09
PHP
Svyatoslav Nemato, 2016-09-03 21:38:09

Checking files on the server at boot?

Question 1.
I check the uploaded files to the server like this:

$finfo 	= finfo_open(FILEINFO_MIME_TYPE); 
$mime 	= finfo_file($finfo, $file);
finfo_close($finfo);

Is this enough, or do I need to install an antivirus on the server?
Question 2.
Found mime file types.
$mime_types = array(
            'txt' => 'text/plain',
            'htm' => 'text/html',
            'html' => 'text/html',
            'xml' => 'application/xml',
      
            // images
            'png' => 'image/png',
            'jpe' => 'image/jpeg',
            'jpeg' => 'image/jpeg',
            'jpg' => 'image/jpeg',
            'gif' => 'image/gif',
            'bmp' => 'image/bmp',

            // archives
            'zip' => 'application/zip',
            'rar' => 'application/x-rar-compressed',

            // audio/video
            'mp3' => 'audio/mpeg',

            // adobe
            'pdf' => 'application/pdf',
            'psd' => 'image/vnd.adobe.photoshop',
            'ai' => 'application/postscript',
            'eps' => 'application/postscript',
            'ps' => 'application/postscript',

            // ms office
            'doc' => 'application/msword',
            'docx'=> 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
            'rtf' => 'application/rtf',
            'xls' => 'application/vnd.ms-excel',
            'xlsx'=> 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
            'ppt' => 'application/vnd.ms-powerpoint',
            'pptx'=> 'application/vnd.openxmlformats-officedocument.presentationml.presentation',

            // open office
            'odt' => 'application/vnd.oasis.opendocument.text',
            'ods' => 'application/vnd.oasis.opendocument.spreadsheet'
        );

But for some reason finfo_file($finfo, $file); produces different mime types for some files, for example txt files. What does it depend on?
The main question.
How to check files uploaded to the server by users?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question