2

i have use dropzone extension to upload images. it work like charm. but i want to upload document files 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;        
                                      }"
                 )
                     ));

But i don't know how to change in this widget.

i change

'mimeTypes' => array('image/jpeg', 'image/png','image/jpg','file/doc','file/xls','file/xlsx','file/docx'),

but it doesn't work. Any answer?

Dhara
  • 1,431
  • 4
  • 29
  • 47

3 Answers3

10

Here i got solution

'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'),  
Dhara
  • 1,431
  • 4
  • 29
  • 47
3

Here i mentioned which mimeType is used for which extension.

For .docx - application/vnd.openxmlformats-officedocument.wordprocessingml.document

For .xlxs - application/vnd.openxmlformats-officedocument.spreadsheetml.sheet

For .doc - application/msword

Here is full list for MIME types of different file extensions.

shah chaitanya
  • 521
  • 4
  • 9
  • If for some users it doesn't work, it might be because of this bug: https://bugs.chromium.org/p/chromium/issues/detail?id=403433 – temo Jul 10 '21 at 21:35
0

I found issue with .docx, a console.log() of the mime type returned this:

application/vnd.openxmlformats-officedocument.wordprocessingml.d

Hope that helps someone. It fixed the issue for me

user1073263
  • 41
  • 1
  • 2