.rar, .zip files MIME Type

后端 未结 6 656
自闭症患者
自闭症患者 2020-11-28 03:52

I\'m developing a simple php upload script, and users can upload only ZIP and RAR files.

What MIME types I should use to check $_FILES[x][type]? (a comp

6条回答
  •  长情又很酷
    2020-11-28 04:27

    As extension might contain more or less that three characters the following will test for an extension regardless of the length of it.

    Try this:

    $allowedExtensions = array( 'mkv', 'mp3', 'flac' );
    
    $temp = explode(".", $_FILES[$file]["name"]);
    $extension = strtolower(end($temp));
    
    if( in_array( $extension, $allowedExtensions ) ) { ///
    

    to check for all characters after the last '.'

提交回复
热议问题