我在
./system/application/config/mimes.php
中添加了这行代码。'dwg' => array('application/acad', 'application/x-acad', 'application/autocad_dwg', 'image/x-dwg', 'application/dwg', 'application/x-dwg', 'application/x-autocad', 'image/vnd.dwg', 'drawing/dwg'),
我尝试上传一个.dwg文件,但出现以下错误:
您尝试上传的文件类型不允许。
如何上传.dwg文件?
$config['file_name'] = date('YmdHis').'_'.rand(0,9).'.'.$this->getFileExt($fieldName); $config['upload_path'] = realpath('./uploads/client/bi/'); $config['allowed_types'] = 'dxf|dwg|dwf|gif|jpg|png|jpeg'; $config['max_size'] = '2000';
我添加了以下行来更改mime设置;'dwf' => array('drawing/x-dwf', 'model/vnd.dwf'),'dwg' => array('application/acad', 'image/vnd.dwg', 'image/x-dwg'), 'dxf' => array('application/dxf', 'image/vnd.dwg', 'image/x-dwg')
。现在它可以完美上传图片,但尝试上传AutoCAD文件时会显示错误。 - Anil Sharmaapplication/octet-stream
并尝试了一下,它起作用了!虽然我解决了这个问题,但仍然想知道为什么那些 MIME 类型不起作用? - Anil Sharma