本文整理汇总了PHP中kartik\file\FileInput类的典型用法代码示例。如果您正苦于以下问题:PHP FileInput类的具体用法?PHP FileInput怎么用?PHP FileInput使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FileInput类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
for(var i = 0; i < arr.length; i++){
if(arr[i] === fileName){
arr.splice(i, 1);
}
}
$("#tour-smallimg").val("");
}']]);
?>
<?php
echo $form->field($model, 'smallimg')->label("")->textInput(['maxlength' => true, 'class' => 'sr-only']);
?>
<?php
echo $form->field($model, 'limg', ['options' => ['name' => 'limg', 'class' => 'form-group']])->label('Largeimg')->widget(FileInput::classname(), ['options' => ['accept' => 'image/*', 'multiple' => true, 'name' => 'smallimg'], 'pluginOptions' => ['uploadUrl' => \yii\helpers\Url::to(['/file-upload/upload']), 'maxFileCount' => 10], 'pluginEvents' => ['fileuploaded' => 'function(event, data, previewId, index){
var lag = $("#tour-largeimg").val().split(" "),
//fileName = data.files[index].name.replace(" (Copy)", "1").replace(" ", "_");
fileName = data.response.files.name;
for(var i = 0; i < lag.length; i++){
if(lag[i] === ""){
lag.splice(i, 1);
}
}
lag.push(fileName);
$("#tour-largeimg").val(lag.join(" "));
}', 'filesuccessremove' => 'function(event, id){
var name = $("#" + id + " img").attr("title"),
fileName = name.replace(" ", "_");
示例2: run
/**
* @inheritdoc
*/
public function run()
{
$id = Html::getInputId($this->model, 'image_deleted');
$options = ['options' => ['accept' => 'image/*'], 'pluginOptions' => ['showUpload' => false], 'pluginEvents' => ['fileclear' => "function() { \$('#{$id}').val(1);}"]];
if ($this->model->imageUrl !== null) {
$options['pluginOptions']['initialPreview'] = [Html::img($this->model->imageUrl, ['class' => 'file-preview-image'])];
}
echo $this->form->field($this->model, 'image_deleted', ['template' => '{input}'])->hiddenInput();
echo $this->form->field($this->model, 'image')->widget(FileInput::classname(), $options);
}
示例3:
<?php
echo $form->field($model, 'o4')->textInput();
?>
<?php
echo $form->field($model, 'o5')->textInput();
?>
<?php
echo $form->field($model, 'o6')->textInput();
?>
<?php
} else {
?>
<div class="form-group">
<?php
echo '<label class="control-label">เพิ่มไฟล์</label>';
echo FileInput::widget(['model' => $model, 'attribute' => 'myfile[]', 'id' => 'upfile', 'options' => ['multiple' => true, 'accept' => '.xlsx', 'style' => 'width: 300px'], 'pluginOptions' => ['showUpload' => false, 'maxFileCount' => 30]]);
?>
</div>
<?php
}
?>
<div class="form-group">
<?php
echo Html::submitButton($model->isNewRecord ? 'บันทึกข้อมูล' : 'แก้ไขข้อมูล', ['id' => 'btnsub', 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
</div>
<?php
ActiveForm::end();
?>
示例4: run
public function run()
{
if (!$this->model || !$this->attribute) {
return null;
}
$extraData = $this->model->isNewRecord ? ['sign' => $this->model->sign] : ['id' => $this->model->id];
$previewImages = [];
$previewImagesConfig = [];
$existModelImages = EntityToFile::find()->where('entity_model_name = :emn', [':emn' => $this->model->formName()]);
if ($this->saveAttribute !== null) {
$existModelImages->andWhere('attribute = :attr', [':attr' => $this->saveAttribute]);
}
$existModelImages = $this->model->isNewRecord ? $existModelImages->andWhere('temp_sign = :ts', [':ts' => $this->model->sign]) : $existModelImages->andWhere('entity_model_id = :id', [':id' => $this->model->id]);
$existModelImages = $existModelImages->orderBy('position DESC')->all();
/**
* @var \common\models\EntityToFile $file
*/
foreach ($existModelImages as $image) {
$fileName = $image->file->base_name . '.' . $image->file->extension;
$previewImages[] = Html::img(FPM::originalSrc($image->file_id), ['class' => 'file-preview-image', 'id' => 'preview-image-' . $image->file_id]);
$previewImagesConfig[] = ['caption' => $fileName, 'width' => '120px', 'url' => ImagesUploadModel::deleteImageUrl(['id' => $image->id]), 'key' => $image->id];
}
$output = Html::hiddenInput('urlForSorting', ImagesUploadModel::sortImagesUrl(), ['id' => 'urlForSorting']);
$output .= Html::hiddenInput('aspectRatio', $this->aspectRatio, ['class' => 'aspect-ratio']);
$output .= FileInput::widget(['model' => $this->model, 'attribute' => $this->attribute, 'options' => ['multiple' => $this->multiple, 'accept' => 'image/*'], 'pluginOptions' => ['dropZoneEnabled' => false, 'browseClass' => 'btn btn-success', 'browseIcon' => '<i class="glyphicon glyphicon-picture"></i> ', 'removeClass' => "btn btn-danger", 'removeIcon' => '<i class="glyphicon glyphicon-trash"></i> ', 'uploadClass' => "btn btn-info", 'uploadIcon' => '<i class="glyphicon glyphicon-upload"></i> ', 'uploadUrl' => Url::to($this->uploadUrl), 'allowedFileTypes' => ['image'], 'allowedPreviewTypes' => ['image'], 'uploadExtraData' => $extraData, 'initialPreview' => $previewImages, 'initialPreviewConfig' => $previewImagesConfig, 'overwriteInitial' => false, 'showRemove' => false, 'otherActionButtons' => $this->render('_crop_button'), 'fileActionSettings' => ['indicatorSuccess' => $this->render('_success_buttons_template')]], 'pluginEvents' => ['fileuploaded' => 'function(event, data, previewId, index) {
var elem = $("#"+previewId).find(".file-actions .file-upload-indicator .kv-file-remove");
var cropElem = $("#"+previewId).find(".file-actions .crop-link");
var img = $("#"+previewId).find("img");
//id for cropped image replace
img.attr("id", "preview-image-"+data.response.imgId);
elem.attr("data-url", data.response.deleteUrl);
elem.attr("data-key", data.response.id);
cropElem.attr("href", data.response.cropUrl);
//Resort images
saveSort();
//Fix crop url for old images
fixMultiUploadImageCropUrl();
}', 'fileloaded' => 'function(file, previewId, index, reader) {
//Fix url for old images
fixMultiUploadImageCropUrl();
}']]);
$output .= '<br>';
$output .= $this->render('_modal');
return $output;
}
示例5:
echo $form->field($model, 'description')->textarea(['rows' => 6]);
?>
<?php
echo $form->field($model, 'type')->dropDownList(['hot' => 'Hot', 'usual' => 'Usual'], ['prompt' => '']);
?>
<?php
echo $form->field($model, 'price')->textInput();
?>
<?php
echo $form->field($model, 'quantity')->textInput();
?>
<?php
echo $form->field($model, 'photo')->widget(FileInput::classname(), ['options' => ['accept' => 'image/*']]);
?>
<div class="form-group">
<?php
echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
</div>
<?php
ActiveForm::end();
?>
</div>
示例6: run
public function run()
{
if ($this->label === null) {
$this->label = Yii::t('mediafile', 'Files');
}
if ($this->newFileLabel === null) {
$this->newFileLabel = Yii::t('mediafile', 'New file');
}
$html = '';
$html .= '<div class="form-group file-preview-wrapper ">';
$html .= '<label class="control-label col col-sm-3">' . $this->label . '</label>';
$html .= '<div class="col col-sm-6">';
foreach ($this->model->mediafiles as $mediafile) {
// Steal classes from kartik's plugin.
if (preg_match('/^image\\//', $mediafile->mediafiletype->mimetype)) {
$html .= '<div class="file-preview-frame">';
} else {
$html .= '<div class="file-preview-frame" style="width: 160px; height: auto; ">';
}
if (preg_match('/^image\\//', $mediafile->mediafiletype->mimetype)) {
$html .= '<img src="' . Url::to(['mediafile/view', 'id' => $mediafile->primaryKey]) . '" style="width: auto; height: 160px;" />';
} else {
//$html .= '<div class="file-preview-other"><i class="glyphicon glyphicon-file"></i></div>';
$name = $mediafile->title;
if (!$name) {
$name = Yii::t('mediafile', 'File') . ' ' . $mediafile->primaryKey;
}
$name = preg_replace('/\\.[^\\.]+$/', '', $name);
$html .= '<div class="file-caption-name">';
$html .= $name;
$html .= '</div>';
$html .= '<div class="file-caption-name">';
$html .= $mediafile->mediafiletype->extension . Yii::t('mediafile', '-file');
$html .= '</div>';
}
$html .= '<br />';
$html .= '<br />';
$html .= '<a href="' . Url::to([$this->unassignAction, 'id' => $this->model->primaryKey, 'mediafile' => $mediafile->primaryKey]) . '" class="btn btn-warning center-block">' . Yii::t('mediafile', 'Unassign') . '</a>';
$html .= '<br />';
$html .= '</div>';
// preview pane
}
$html .= '</div>';
// col
$html .= '</div>';
// form-group
$html .= '<div class="file-upload-wrapper">';
// HACK: if you do not manually append [] to the name of the
// attribute, only one file will be uploaded.
$html .= $this->form->field($this->model, 'newFiles[]')->widget(FileInput::classname(), ['options' => ['accept' => ['image/*', 'video/*'], 'multiple' => true], 'pluginOptions' => ['showUpload' => false, 'maxFileCount' => $this->maxFileCount, 'autoReplace' => true]])->label($this->newFileLabel);
$html .= '</div>';
return $html;
}
示例7: explode
?>
<?php
echo $form->field($model, 'mode')->dropDownList(Ad::getAdMode());
?>
<?php
echo $form->field($model, 'title')->textInput(['maxlength' => true]);
?>
<?php
echo $form->field($model, 'short_code')->textInput(['maxlength' => true]);
?>
<?php
echo $form->field($model, 'pic_url')->hint('<i class="fa fa-info-circle"></i> ' . Yii::t('fileinput', 'Note: Limit upload one picture.'))->widget(FileInput::classname(), ['options' => ['accept' => 'image/*', 'multiple' => false], 'pluginOptions' => ['uploadUrl' => Url::to(['/cms/ad/file-upload']), 'uploadAsync' => true, 'initialPreview' => General::showImages($model->pic_url), 'initialPreviewConfig' => General::showLinks($model->pic_url, 'pic_url', 'ad', '/cms/ad/file-upload'), 'previewFileType' => 'any', 'overwriteInitial' => true, 'maxFileSize' => Yii::$app->params['config']['config_pic_size'], 'allowedFileExtensions' => explode(',', Yii::$app->params['config']['config_pic_extension']), 'allowedFileTypes' => ['image'], 'maxFileCount' => 1, 'uploadExtraData' => ['dir' => 'ad', 'name' => 'Ad[pic_url]', 'route' => '/cms/ad/file-upload', 'field' => 'pic_url']]]);
?>
<?php
/*
FileInput::widget([
'name' => 'pic_url',
'options'=>[
'accept' => 'image/*',//只接收图片类型
'multiple'=>false,//这里不需要多选
],
'pluginOptions' => [
'uploadUrl' => Url::to(['/cms/ad/file-upload']),
// 'uploadAsync' => true,//异步上传
'initialPreview'=>[
//Html::img("/images/moon.jpg", ['class'=>'file-preview-image', 'alt'=>'The Moon', 'title'=>'The Moon']),
示例8:
/* @var $model common\models\User */
$this->title = 'Profile: ' . $model->username;
$this->params['breadcrumbs'][] = ['label' => 'Profile', 'url' => ['view']];
?>
<div class="user-view">
<h1><?php
echo Html::encode($model->username);
?>
</h1>
<?
$form = ActiveForm::begin();
echo $form->field($model, 'imgsource')->widget(FileInput::className(), [
'options' => [
'accept' => 'image/*',
],
'pluginOptions' => [
'uploadUrl' => Url::to(['file-upload-avatar']),
'allowedFileExtensions' => ['jpg', 'png', 'gif', 'jpeg'],
'initialPreview' => $image,
'showUpload' => true,
'showRemove' => false,
'dropZoneEnabled' => false,
]
]);
?>
示例9:
?>
-image">
<?php
Modal::end();
}
?>
<div id="field-<?php
echo $selector;
?>
" class="form-group uploader">
<div class="fullinput">
<div class="uploader-browse">
<?php
echo FileInput::widget(['model' => $model, 'attribute' => $attribute, 'options' => ['id' => $selector, 'onchange' => 'readFile(this, "' . $selector . '", ' . (int) $crop . ', ' . Json::encode($jcropSettings) . ')'], 'pluginOptions' => ['showRemove' => false, 'uploadAsync' => false, 'showUpload' => false, 'showUploadedThumbs' => false, 'showPreview' => false, 'previewFileType' => false]]);
?>
</div>
</div>
<?php
if ($crop) {
?>
<?php
echo Html::hiddenInput($model->formName() . "[{$attribute}-coords][x]", null, ['id' => "{$selector}-coords-x"]);
?>
<?php
echo Html::hiddenInput($model->formName() . "[{$attribute}-coords][w]", null, ['id' => "{$selector}-coords-w"]);
?>
<?php
echo Html::hiddenInput($model->formName() . "[{$attribute}-coords][y]", null, ['id' => "{$selector}-coords-y"]);
?>
示例10:
</div>
</div>
<div class="row">
<div class="col-md-4"><?php
echo $form->field($model, 'drivers_passport')->textInput(['maxlength' => true]);
?>
</div>
<div class="col-md-4"> <?php
echo $form->field($model, 'drivers_licence')->textInput(['maxlength' => true]);
?>
</div>
</div>
<div class="row">
<div class=" col-md-12">
<?php
echo $form->field($model, 'docs[]')->widget(FileInput::classname(), ['options' => ['accept' => 'image/*', 'multiple' => true], 'pluginOptions' => ['initialPreview' => $model->initialPreview($model->docs, 'docs', 'file'), 'initialPreviewConfig' => $model->initialPreview($model->docs, 'docs', 'config'), 'allowedFileExtensions' => ['pdf', 'jpg'], 'showPreview' => true, 'showCaption' => true, 'showRemove' => true, 'showUpload' => true, 'overwriteInitial' => false]])->label(false);
?>
</div>
</div>
<?php
if ($model->isNewRecord) {
echo $form->field($model, 'appilcant_id')->hiddenInput(['maxlength' => true, 'value' => $id])->label(false);
} else {
echo $form->field($model, 'appilcant_id')->hiddenInput(['maxlength' => true])->label(false);
}
?>
<?php
//$form->field($model, 'appilcant_id')->textInput(['maxlength' => true, 'value' => $id])->label(false)
?>
示例11:
<div class="modal-body">
<div class="row">
<div class="col-xs-12">
<?php
echo $form->field($model, 'nombre', $inputOpciones)->textInput(['class' => $inputClase, 'autocomplete' => 'off']);
?>
<span class="glyphicon glyphicon-ok form-control-feedback"></span>
<?php
//$form->field($model, 'icono', $inputOpciones)->fileInput(['class' => $inputClase])
?>
<?php
// your fileinput widget for single file upload
echo $form->field($model, 'imagenes')->widget(FileInput::classname(), ['options' => ['accept' => 'image/*'], 'pluginOptions' => ['allowedFileExtensions' => ['jpg', 'gif', 'png'], 'showCaption' => true, 'showRemove' => false, 'showUpload' => false, 'showPreview' => false, 'browseClass' => 'btn ink-reaction btn-primary btn-block', 'browseIcon' => '<i class="md md-photo-camera"></i> ', 'browseLabel' => 'Seleccionar icono']])->label(false);
?>
<?php
echo $form->field($model, 'estado')->radioList($model->listadoEstados(), $inputRadioListOpciones)->label($model->getAttributeLabel('tipo'), ['style' => 'margin-bottom: 10px;']);
?>
<span class="opacity-50"><?php
echo $model->getAttributeLabel('descripcion');
?>
</span>
<?php
echo $form->field($model, 'descripcion')->textarea(['class' => $inputClase . ' editorTexto control-3-rows', 'style' => 'margin-top:10px', 'placeholder' => 'Me describo como...'])->label(false);
?>
</div>
</div>
示例12:
* @var app\models\TESTIMONIALS $model
* @var yii\widgets\ActiveForm $form
*/
$this->registerJsFile("//cdn.tinymce.com/4/tinymce.min.js");
?>
<div class="testimonials-form">
<?php
$form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]);
?>
<?php
echo $form->field($model, 'comment')->textarea(['rows' => 6]);
?>
<?php
echo FileInput::widget(['model' => $model, 'attribute' => 'image', 'pluginOptions' => ['initialPreview' => [], 'initialCaption' => "User Image", 'overwriteInitial' => false, 'options' => ['accept' => 'image/*'], 'pluginOptions' => ['allowedFileExtensions' => ['jpg', 'gif', 'png']]]]);
?>
<div class="form-group">
<?php
echo Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
</div>
<?php
ActiveForm::end();
?>
</div>
<?php
示例13: UploadedFiles
use yii\bootstrap\ActiveForm;
use yii\helpers\Html;
use kartik\dynagrid\DynaGrid;
use yii\helpers\Url;
/* @var $this yii\web\View */
/* @var $searchModel app\models\Fregat\DocfilesSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Загруженные файлы';
$this->params['breadcrumbs'] = Proc::Breadcrumbs($this);
?>
<div class="docfiles-index">
<?php
$form = ActiveForm::begin();
?>
<?php
echo $form->field($model, 'docFile')->widget(FileInput::classname(), ['pluginOptions' => ['uploadUrl' => Url::to(['Fregat/docfiles/create']), 'dropZoneEnabled' => false, 'previewZoomSettings' => ['image' => ['width' => 'auto', 'height' => '100%']]], 'pluginEvents' => ["fileuploaded" => 'function(event, data, previewId, index) { UploadedFiles("docfilesgrid", event, data); }']]);
?>
<?php
ActiveForm::end();
?>
<?php
$result = Proc::GetLastBreadcrumbsFromSession();
$foreign = isset($result['dopparams']['foreign']) ? $result['dopparams']['foreign'] : '';
echo DynaGrid::widget(Proc::DGopts(['options' => ['id' => 'docfilesgrid'], 'columns' => Proc::DGcols(['columns' => [['attribute' => 'docfiles_ext', 'format' => 'raw', 'value' => 'docfiles_iconshow', 'contentOptions' => ['style' => 'width: 40px; text-align: center;'], 'filter' => false], ['attribute' => 'docfiles_name', 'format' => 'raw', 'value' => 'docfiles_name_html'], ['attribute' => 'docfiles_hash', 'visible' => false]], 'buttons' => array_merge(empty($foreign) ? [] : ['chooseajax' => ['Fregat/docfiles/assign-to-select2']], Yii::$app->user->can('DocfilesEdit') ? ['deleteajax' => ['Fregat/docfiles/delete']] : [])]), 'gridOptions' => ['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'panel' => ['heading' => '<i class="glyphicon glyphicon-file"></i> ' . $this->title]]]));
?>
</div>
示例14: array
<?php
$language_items = [];
foreach ($languages as $key => $language) {
$field = $form->field($model, "name_{$language->url}")->textInput(['maxlength' => true])->label('Name');
if ($languageDefault->url == $language->url) {
$field = $form->field($model, "name")->textInput(['maxlength' => true]);
}
$language_items[] = ['label' => Yii::t('backend', $language->name), 'content' => "<p>{$field}</p>", 'active' => $key == 0];
}
echo Tabs::widget(['items' => $language_items]);
?>
<?php
echo $form->field($model, 'file')->widget(FileInput::classname(), ['options' => ['multiple' => false, 'accept' => 'pdf/*'], 'pluginOptions' => ['previewFileType' => 'image', 'showUpload' => false]])->label(Yii::t('backend', 'PDF File'));
?>
<?php
echo Html::a($model->file, $model->getUploadedFileUrl('file'), array('target' => '_blank'));
?>
<br/><br/>
<?php
echo $form->field($model, 'order')->textInput();
?>
<?php
echo $form->field($model, 'id')->hiddenInput();
?>
示例15: replace
var tpl = '<div class = "col-md-4"><div class="thumbnail"><p>'
+ '<a href="{$editAction}" class="imgaction blue" title="Редактировать">'
+ '<i class="glyphicon glyphicon-pencil"></i></a>'
+ '<a href="#" class="imgaction red pull-right" title="Удалить" data-id="{id}">'
+ '<i class="glyphicon glyphicon-trash"></i></a></p>'
+ '<img src="{thumb}">'
+ '<p><a href="#" class="imgaction grey" title="Сделать главным" data-id="{id}">'
+ '<i class="glyphicon glyphicon-ok"></i></a></p></div></div>';
for(var i in data.response) {
var el = tpl.replace('{id}', data.response[i].id).
replace('{thumb}', data.response[i].thumb);
\$(el).appendTo('#page-images');
}
}
fileuploaded;
echo FileInput::widget(['name' => 'files', 'options' => ['accept' => 'image/*', 'multiple' => true], 'pluginOptions' => ['uploadUrl' => Url::to(['image/ajax-upload', 'table' => $model::$tableId, 'id' => $model->id]), 'maxFileCount' => 5, 'browseClass' => 'btn btn-success', 'uploadClass' => 'btn btn-info', 'removeClass' => 'btn btn-danger', 'removeIcon' => '<i class="glyphicon glyphicon-trash"></i> ', 'dropZoneEnabled' => false], 'pluginEvents' => ['fileuploaded' => $jsUploaded]]);
?>
</div>
<hr>
<div id="page-images" class="row">
<?php
if ($files != null) {
foreach ($files as $f) {
$f->attachBehavior('imageBehavior', ['class' => \app\components\imageBehavior::className()]);
?>
<div class = "col-md-4">
<div class="thumbnail">
<p>
<a href="<?php
echo Url::to(['image/edit', 'id' => $f->id]);
?>