我使用dropzone扩展来上传图像。它像魅力一样工作。但我想上传文档文件doc,docx,xls,xlsx。
$this->widget('ext.dropzone.EDropzone', array(
'model' => $model,
'attribute' => 'image_name',
'url' => Yii::app()->request->baseUrl.'/jobMaster/ImageUpload',
'mimeTypes' => array('image/jpeg', 'image/png','image/jpg'),
'onSuccess' => 'succcesupload',
//'maxFilesize'=> 5,
'options' => array(
'addRemoveLinks'=> true,
'removedfile'=> "js:function(file) {
var name = file.name;
$.ajax({
type: 'POST',
url: '".$this->createUrl('/jobMaster/deleteImageUpload')."',
data: 'id='+name,
dataType: 'html'
});
var _ref;
return (_ref = file.previewElement) != null ? _ref.parentNode.removeChild(file.previewElement) : void 0;
}"
)
));
但我不知道如何改变这个小部件。
我改变
'mimeTypes' => array('image/jpeg', 'image/png','image/jpg','file/doc','file/xls','file/xlsx','file/docx'),
但它不起作用。有答案吗?
我在这里得到解决方案
'mimeTypes' => array('image/jpeg', 'image/png','image/jpg','application/vnd.ms-excel','application/vnd.openxmlformats-officedocument.wordprocessingml.document','application/docx','application/pdf','text/plain','application/msword','application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'),
我发现.docx的问题,mime类型的console.log()返回了这个:
应用/ vnd.openxmlformats-officedocument.wordprocessingml.d
希望能帮助别人。它解决了我的问题
这里我提到哪个mimeType用于哪个扩展名。
对于.docx - application / vnd.openxmlformats-officedocument.wordprocessingml.document
对于.xlsx - application / vnd.openxmlformats-officedocument.spreadsheetml.sheet
对于.doc - application / msword
Here是不同文件扩展名的MIME类型的完整列表。