kartik\file\FileInput input 的 value 上没有地址数据 [ 2.0 版本 ]
kartik\file\FileInput
异步上传成功后地址没有返回到 input 的 value 上,这个是什么原因?
҉ 加载中... 补充于 2019-03-27 16:12
public function actionUpload()
{
$model = new Shop();
$model->pict_url = UploadedFile::getInstances($model, 'pict_url');
$images = '';
if ($model->pict_url) {
foreach ($model->pict_url as $file) {
$img_name =date("YmdHis").'_'.rand(10,99);
$file->saveAs('juxd/uploads/' . $img_name . '.' . $file->extension);
$images .= 'juxd/uploads/'.$img_name.'.'.$file->extension;
}
$model->pict_url = $images;
return json_encode($model->pict_url);
}
}
<?= $form->field($model, 'pict_url[]')->widget(FileInput::classname(), [
'name' => 'quality_report',
'pluginOptions' => [
'uploadUrl'=>Url::to("upload"),
'browseOnZoneClick'=>true,
'uploadAsync'=> true,
'maxFileCount'=> 10,
'minFileCount'=> 1,
'validateInitialCount'=> true,
'overwriteInitial'=> false,
'getImageUrl' => true,
'initialPreviewConfig' => [],
'allowedFileExtensions' => ["jpg", "png","gif"],
],
'options' => [
'accept' => 'image/*',
'multiple'=> true,
],
]); ?>
҉ 加载中... 补充于 2019-03-29 15:05
'pluginEvents' => [
//选择文件后给input加id
'filebatchselected'=>"function(event, files) {
$('.field-shop-shop_pic').show().find('input').attr('id','shop_pic');
}",
'fileuploaded' => "function (object,data,previewId, index){console.log(data);
$('#shop_pic').val($('#shop_pic').val()+';'+data.response);
}",
'error' => "function (){
alert('图片上传失败');
}",
"filebeforedelete" => "function (event, key, jqXHR, data) {
console.log(key);
var aborted = !window.confirm('你确定要删除该图片吗?');
if (aborted) {
//window.alert('File deletion was aborted! ');
};
return aborted;
}",
]
共 0 个回答
没有找到数据。
҉ 加载中... 广东深圳
注册时间:2018-12-24
最后登录:2019-09-03
在线时长:29小时21分
最后登录:2019-09-03
在线时长:29小时21分
- 粉丝2
- 金钱1975
- 威望0
- 积分2265