如何检查只有 .txt 文件上传到服务器,而不是 php 中的其他文件。
最佳答案
您可以测试文件类型:
if ($_FILES['file']['type'] == 'text/plain') // this file is TXT
此外,您还可以使用函数 mime_content_type 来验证文件的 mime 类型.
关于php - 只上传txt文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4188005/