问题
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