对于 xml 文件,似乎
$finfo->file()
返回 application/xml
而不是 text/xml
。
将具有有效 mime 类型的数组更改为:
array(
'xml' => 'application/xml',
'txt' => 'text/plain',
),
这对我有用......
'xml' => ['text/xml', 'application/xml'],
'txt' => 'text/plain',
尝试使用下面的代码。文件的扩展名在您的代码上正确。
if (!move_uploaded_file( $_FILES['upfile']['tmp_name'], 'uploads/'.basename($_FILES["upfile"]["name"] ) ))