yii CMultiFileUpload stop default behavior

一世执手 提交于 2019-12-25 02:43:07

问题


How are you supposed to prevent the CMultiFileUpload widget from appending the file names of selected files to the page?

Here is my code:

<?php
$this->widget('CMultiFileUpload', array(
    'name' => 'images',
    'accept' => 'jpeg|jpg|gif|png',
    'denied' => 'Invalid file type',
    'htmlOptions' => array('multiple'=>'multiple'),
));?>

Here is a picture of what I am talking about:

I need to remove what the arrows point to. It's also strange why it says "No files selected" when that isn't the case. If I submit the form, the file does indeed get sent to the server.

Edit: It does what I want if javascript is turned off though. It also fixes the "no files selected" error. Is there a way to disable the javascript for just the widget?


回答1:


if you want to hide the names of the files you have uploaded then you can use the options in your CMultiFIleUpload eg:-

<?php
$this->widget('CMultiFileUpload', array(
    'name' => 'images',
    'accept' => 'jpeg|jpg|gif|png',
    'denied' => 'Invalid file type',
    'htmlOptions' => array('multiple'=>'multiple'),
    'options'=>array(
     'onFileAppend'=>'
                    function(e,v,m)
                     {
                       // try using e.preventDefault();
                    (".MultiFile-label").css("display","none");
                    }
                    '
)
));?>

Note:- I haven't tested it but hope it helps.



来源:https://stackoverflow.com/questions/21538453/yii-cmultifileupload-stop-default-behavior

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!