0

我正在尝试允许上传扩展名为 .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>';
    }
4

0 回答 0