以下是我用于视频和图像上传的代码。图片预览显示为选择,但是当我选择要上传的视频时,它将上传但不显示任何预览。
任何建议,如果我缺少一些东西。
$form->field($model, 'sessionvideos')->widget(FileInput::classname(), [
'options' => ['accept' => 'pdf', 'mp3', 'mp4', 'multiple' => true],
'pluginOptions' => [
'previewFileType' => 'any',
'validateInitialCount' => true,
'initialPreviewAsData' => true,
'allowedFileExtensions' => ['pdf', 'mp3', 'mp4'],
'maxFileCount' => 18,
'showUpload' => false,
]]);
答案 0 :(得分:0)
echo $form->field($model, 'video_file')->widget(FileInput::class, [
'options'=>[
'multiple'=>false,
'accept'=>'video/*'
],
'pluginOptions' => [
'initialPreview'=> Yii::getAlias("@web/files/video.mp4"),
'overwriteInitial'=>true,
'showUpload' =>false,
'allowedFileExtensions'=>['mp4'],
'initialPreviewAsData'=>true,
'initialPreviewFileType'=> 'video',
'initialPreviewConfig'=> [
['filetype'=> "video/mp4"]
],
],
]);
答案 1 :(得分:0)
echo $form->field($model, 'temp_video',[
'options' => [
'tag' => 'div',
'class' => 'form-group label-floating
'],
'template' => '{label}{input}{error}{hint}'])->widget(FileInput::classname(), [
'options' => ['multiple' => false,'accept' => 'video/*', 'class' => 'uploadImages'],
'pluginOptions' => [
'showCaption'=> false,
'dropZoneEnabled'=>false,
'showCancel'=>false,
'showRemove'=>false,
'initialPreview'=> [ $model->image ? Yii::$app->urlManagerFrontEnd->createAbsoluteUrl(['uploads/news/'.$model->image]):''],
'overwriteInitial'=>true,
'showUpload' =>false,
'allowedFileExtensions'=>['mp4', 'mpeg'],
'initialPreviewAsData'=>true,
'initialPreviewFileType'=> 'video',
'initialPreviewConfig'=> [
['filetype'=> "video/mp4"],
['caption'=> $model->image ? $model->image : '']
],
],
])->label(false);