我试图允许上传扩展名为.iges,.dxf,.dwg的文件。 该脚本将上传jpg,png& pdf文件,但有iges,.dxf,.dwg,.extensions。
这是我正在使用的代码:
//验证类型。应该是JPEG或PNG。
$allowed = array ('application/pdf', 'application/DXF','application/dxf', 'application/dwg','application/DWG', 'image/pjpeg', 'image/jpeg', 'image/JPG', 'image/X-PNG', 'image/PNG', 'image/png', 'image/x-png',);
if (in_array($_FILES['upload']['type'], $allowed)) {
// Move the file over.
if (move_uploaded_file ($_FILES['upload']['tmp_name'], "uploads/{$_FILES['upload']['name']}")) {
echo '<p><em>The file has been uploaded!</em></p>';
} // End of move... IF.
} else { // Invalid type.
echo '<p class="error">Please upload correct file type</p>';
}