Limiting file upload type
问题 Simple question. Is there a way to only allow txt files upon uploading? I've looked around and all I find is text/php , which allows PHP. $uploaded_type=="text/php 回答1: When you upload a file with PHP its stored in the $_FILES array. Within this there is a key called "type" which has the mime type of the file EG $_FILES['file']['type'] So to check it is a txt file you do if($_FILES['file']['type'] == 'text/plain'){ //Do stuff with it. } It's explained very well here. Also, don't rely on file