Widget to render the jQuery File Upload UI plugin as shown in its demo
Author: Alexander Kochetov (creocoder@gmail.com)
Inheritance: extends BaseUpload
Example #1
2
<?php

use dosamigos\fileupload\FileUploadUI;
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $searchModel yeesoft\media\models\Media */
$this->title = Yii::t('yee/media', 'Upload New File');
if ($mode !== 'modal') {
    $this->params['breadcrumbs'][] = $this->title;
}
?>

<div class="panel panel-default">
    <div class="panel-body">
        <div id="uploadmanager">
            <p>
                <?php 
echo Html::a('← ' . Yii::t('yee/media', 'Back to file manager'), $mode == 'modal' ? ['manage/index', 'mode' => 'modal'] : ['default/index']);
?>
            </p>

            <?php 
echo FileUploadUI::widget(['model' => $model, 'attribute' => 'file', 'formView' => '@vendor/yeesoft/yii2-yee-media/views/upload-widget/form', 'uploadTemplateView' => '@vendor/yeesoft/yii2-yee-media/views/upload-widget/upload', 'downloadTemplateView' => '@vendor/yeesoft/yii2-yee-media/views/upload-widget/download', 'clientOptions' => ['autoUpload' => Yii::$app->getModule('media')->autoUpload], 'url' => ['upload'], 'gallery' => false]);
?>

        </div>
    </div>
</div>
Example #2
0
 public function init()
 {
     parent::init();
     $this->formView = '@vendor/albertborsos/yii2-lib/views/fileupload/form';
     $this->fieldOptions['id'] = ArrayHelper::getValue($this->options, 'id');
     $this->options['id'] .= '-form';
     $this->options['enctype'] = 'multipart/form-data';
     $this->options['uploadTemplateId'] = $this->uploadTemplateId ?: '#template-upload';
     $this->options['downloadTemplateId'] = $this->downloadTemplateId ?: '#template-download';
 }
<?php

use dosamigos\fileupload\FileUploadUI;
// without UI
$this->title = 'File Upload';
?>


<?php 
echo FileUploadUI::widget(['model' => $model, 'attribute' => 'file_name', 'url' => ['files/upload'], 'options' => ['accept' => 'image/*'], 'clientOptions' => ['maxFileSize' => 2000000]]);
<?php

use dosamigos\fileupload\FileUploadUI;
use derekisbusy\filemanager\Module;
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $searchModel derekisbusy\filemanager\models\Mediafile */
?>

<header id="header"><span class="glyphicon glyphicon-upload"></span> <?php 
echo Module::t('main', 'Upload manager');
?>
</header>

<div id="uploadmanager">
    <p><?php 
echo Html::a('← ' . Module::t('main', 'Back to file manager'), ['file/filemanager', 'related' => $related, 'itemId' => $itemId, 'tempId' => $tempId]);
?>
</p>
    <?php 
echo FileUploadUI::widget(['model' => $model, 'attribute' => 'file', 'clientOptions' => ['autoUpload' => Yii::$app->getModule('filemanager')->autoUpload], 'url' => ['upload', 'related' => $related, 'itemId' => $itemId, 'tempId' => $tempId], 'gallery' => false]);
?>
</div>
Example #5
0
<?php

/* @var $this yii\web\View */
use dosamigos\fileupload\FileUploadUI;
\app\modules\core\components\Modal::begin(['header' => $header, 'toggleButton' => ['label' => '<i class="glyphicon glyphicon-picture"></i> ' . $label, 'class' => 'btn btn-primary'], 'size' => \yii\bootstrap\Modal::SIZE_LARGE]);
?>
    <br/>
<?php 
echo FileUploadUI::widget(['options' => ['id' => 'image-upload-' . $lang], 'model' => $model, 'attribute' => 'file', 'url' => ['/core/image/upload', 'model' => $model->model, 'primaryKey' => $primaryKey], 'gallery' => false, 'fieldOptions' => ['accept' => $extensions], 'clientOptions' => ['maxNumberOfFiles' => $maxNumberOfFiles]]);
?>

<?php 
\app\modules\core\components\Modal::end();
?>

<?php 
if ($fileUploadData) {
    $this->registerJsFile(\yii\helpers\Url::base() . '/js/sortable/jquery-ui.min.js', ['depends' => '\\yii\\web\\JqueryAsset']);
    $this->registerJs('
        var uploadElement = $("#image-upload-' . $lang . '-form");
        var e = {
            isDefaultPrevented:function(){return false}
        };
        uploadElement.fileupload("option", "done").call(uploadElement, e, {
            result: {files:' . $fileUploadData . '},
        });
        $(".files").sortable({
            stop: function( event, ui ) {
                var data = [];
                $(".files tr").each(function(){
                    var str = $(".name a",this).text();
<?php

use dosamigos\fileupload\FileUploadUI;
use oknetsun\admin\AdminModule as Module;
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $searchModel app\oknet\admin\models\Mediafile */
?>

<header id="header"><span class="glyphicon glyphicon-upload"></span> <?php 
echo Module::t('main', 'Upload manager');
?>
</header>

<div id="uploadmanager">
    <p><?php 
echo Html::a('← ' . Module::t('main', 'Back to file manager'), ['file/filemanager']);
?>
</p>
    <?php 
echo FileUploadUI::widget(['model' => $model, 'attribute' => 'file', 'clientOptions' => ['autoUpload' => Yii::$app->getModule('admin')->autoUpload], 'url' => ['upload'], 'gallery' => false]);
?>
</div>
<?php

use dosamigos\fileupload\FileUploadUI;
echo FileUploadUI::widget(['model' => $model, 'attribute' => 'image', 'url' => ['media/upload', 'id' => $tour_id], 'gallery' => false, 'fieldOptions' => ['accept' => 'image/*'], 'clientOptions' => ['maxFileSize' => 10000000], 'clientEvents' => ['fileuploaddone' => 'function(e, data) {
                                    console.log(e);
                                    console.log(data);
                                }', 'fileuploadfail' => 'function(e, data) {
                                    console.log(e);
                                    console.log(data);
                                }']]);
Example #8
0
	<div class="category_product_cont" style="display:none;">
		<?php 
echo FileUploadUI::widget(['model' => $model, 'attribute' => 'cat_title', 'url' => ['productcategory/upload_product'], 'gallery' => false, 'fieldOptions' => ['accept' => 'image/*'], 'clientOptions' => ['maxFileSize' => 2000000, 'downloadTemplateId' => null], 'clientEvents' => ['fileuploadsubmit' => 'function(e, data) {
                                                        var inputs = data.context.find(":input");
                                                        if (inputs.filter(function () {
                                                                return !this.value && $(this).prop("required");
                                                            }).first().focus().length) {
                                                            data.context.find("button").prop("disabled", false);
                                                            return false;
                                                        }
                                                        data.formData = inputs.serializeArray();
                                                        data.formData.push({"name":"id","value": $(".category_id_hidden").val()});
                                                        console.log(data.formData);
                                                    }', 'fileuploaddone' => 'function(e, data) {
                                                         console.log(data);
                                                        $.each(data._response.result.files, function (index, file) {
                                                            console.log(file.name);
                                                            
                                                        });

                                                        $(".category_product_list").append(data._response.result.view);

                                                    }', 'fileuploadfail' => 'function(e, data) {
                                                        console.log(e);
                                                        console.log(data);
                                                    }', 'fileuploaddestroy' => 'function(e, data) {
                                                        
                                                        console.log(data);
                                                    }']]);
?>
	</div>
foreach ($models as $m) {
    echo '<div class="col-xs-6 col-sm-4 col-md-3 image-thumbnail">';
    echo Html::a('<img src="' . $path . $m->thumbnail_url . '" style="height:' . $this->context->module->thumbnails[0][1] . 'px;">', ['view', 'id' => $m->id], ['class' => 'thumbnail', 'data-id' => $m->id]);
    echo '</div>';
}
?>
                        </div>
                    </div>
                    <div class="upload-images" id="filemanagerUpload">
                        <?php 
echo FileUploadUI::widget(['model' => $model, 'attribute' => 'file_name', 'url' => ['files/upload'], 'options' => ['accept' => 'image/*', 'done' => 'filemanager'], 'clientOptions' => ['maxFileSize' => 2000000], 'clientEvents' => ['fileuploaddone' => 'function(e, data) {
                                        console.log(data);
                                        $.each(data.result.files, function( index, value ){
                                            console.log(value);
                                            $("#fileGridManager .row").prepend(\'<div class="col-xs-6 col-sm-4 col-md-3 image-thumbnail"><a class="thumbnail" href="' . Url::to(['view']) . '?id=\' + value.id + \'" data-id="\' + value.id + \'"><img src="\' + value.thumbnailUrl + \'"></a></div>\');
                                            $(\'#filemanagerUpload\').hide();
                                            $(\'#fileGridManager,#fileGridFooter\').show();
                                        });
                                    }', 'fileuploadfail' => 'function(e, data) {
                                        console.log(e);
                                        console.log(data);
                                    }']]);
?>
                    </div>
                </div>

                <div class="panel-footer" id="fileGridFooter">
                    <?php 
echo linkPager::widget(['pagination' => $dataProvider->pagination]);
?>
                </div>
Example #10
0
<?php

//$this->registerJsFile('/js/custom/uploader.js');
// with UI
use dosamigos\fileupload\FileUploadUI;
?>
<div id="content">
    <div class="outer">
        <div class="inner bg-light lter">
            <div id="collapse4" class="body">
                <!--Begin Datatables-->
                <div class="image-index">
                    <?php 
echo FileUploadUI::widget(['model' => new \common\models\ImageSlider(), 'attribute' => 'file', 'url' => ['/image/upload-submit'], 'gallery' => false, 'fieldOptions' => ['accept' => 'image/*']]);
?>
                    <div id="progress">
                        <div class="bar" style="width: 0%;"></div>
                    </div>

                </div>

            </div>

        </div>

    </div>

</div>


<style>
Example #11
0
        <?php 
echo Html::a(Yii::t('app', 'Update'), ['update', 'id' => $model->id], ['class' => 'btn btn-primary']);
?>
        <?php 
echo Html::a(Yii::t('app', 'Change Password'), ['change-password', 'id' => $model->id], ['class' => 'btn btn-primary']);
?>
        <?php 
echo Html::a(Yii::t('app', 'Delete'), ['delete', 'id' => $model->id], ['class' => 'btn btn-danger', 'data' => ['confirm' => Yii::t('app', 'Are you sure you want to delete this item?'), 'method' => 'post']]);
?>
    </p>

    <?php 
echo Html::img($model->getProfilePictureUrl(), ['id' => 'image-profile', 'class' => 'img-thumbnail', 'style' => 'height: 180px;']);
?>
    <br/><br/>

    <?php 
echo FileUploadUI::widget(['model' => $model, 'attribute' => 'profile_pic', 'url' => ['/admin/sys-user/upload-profile-picture', 'id' => $model->id], 'gallery' => false, 'fieldOptions' => ['accept' => 'image/*', 'multiple' => false], 'clientOptions' => ['maxFileSize' => 2000000, 'autoUpload' => true], 'clientEvents' => ['fileuploaddone' => 'function(e, data) {
                                    jQuery("#image-profile").attr("src",data.result.url);
                                }', 'fileuploadfail' => 'function(e, data) {
                                    alert("Image Upload Failed, please try again.");
                                }']]);
?>
    
    
    <?php 
echo DetailView::widget(['model' => $model, 'attributes' => ['id', 'username', ['label' => Yii::t('app', 'Full Name'), 'value' => "{$model->first_name} {$model->last_name}"], 'email:email', ['attribute' => 'temp_pswd_flag', 'value' => Html::tag('span', $model->temp_pswd_flag ? Yii::t('app', 'Active') : Yii::t('app', 'Not set'), ['class' => 'label' . ($model->temp_pswd_flag ? ' label-warning' : ' label-default')]), 'format' => 'raw'], 'last_pswd_reset:datetime', 'next_pswd_reset', 'creation_date:datetime', 'last_update:datetime', ['attribute' => 'idsys_creator', 'value' => "{$model->idsysCreator->first_name} {$model->idsysCreator->last_name}"], ['attribute' => 'idsys_updater', 'value' => "{$model->idsysUpdater->first_name} {$model->idsysUpdater->last_name}"]]]);
?>

</div>
Example #12
0
    <h2><?php 
echo Html::encode($this->title);
?>
</h2>
    
    <?php 
if (count($galleryModel->photos) > 0) {
    ?>
        <hr>
        <?php 
    echo $this->renderAjax('_photosList', ['photos' => $galleryModel->photos]);
    ?>
        
        <hr>
        <?php 
    $this->registerJs("\n                (function(\$) {    \n    \n                    \$('.gallery-photos').on('click', '.gallery-photo-delete', function() {\n\n                        var url = \$(this).data('url');\n                        \$imgBlock = \$(this).closest('li');\n                                                \n\n                        \$.ajax({\n                            url: url,\n                            type: 'POST',\n                            success: function() {\n                                \$imgBlock.remove();\n                            }\n                        });\n                    });\n                })(jQuery);\n           ");
    ?>
    <?php 
} else {
    ?>
    <p><i>Нет изображений</i></p>
    <?php 
}
?>
        

    <?php 
echo FileUploadUI::widget(['model' => $photoModel, 'attribute' => 'file', 'url' => ['gallery-photo/upload', 'id' => $galleryModel->id], 'gallery' => false]);
?>
</div>
Example #13
0
 * Created by PhpStorm.
 * User: ivphpan
 * Date: 10.12.15
 * Time: 20:31
 * @var $this \yii\web\View
 * @var $model \app\models\Document
 * @var $fileUploadData string
*/
\app\assets\SortableAsset::register($this);
use yii\helpers\Url;
?>
<div class="row">
    <div class="col-md-12">
        <div class="well">
            <?php 
echo \dosamigos\fileupload\FileUploadUI::widget(['model' => new \app\models\Attachment(), 'attribute' => 'file', 'url' => ['/attachment/upload', 'documentId' => $model->id], 'gallery' => false, 'fieldOptions' => ['accept' => 'image/*'], 'clientOptions' => ['maxFileSize' => 2000000, 'disableImagePreview' => true, 'uploadedBytes' => true]]);
if ($fileUploadData) {
    $this->registerJs('
                var $el = $("#attachment-file-form");
                var e = {
                    isDefaultPrevented:function(){return false}
                };
                $el.fileupload("option", "done").call($el, e, {
                    result:' . $fileUploadData . ',
                });

                $(".files").sortable({
                    stop: function( event, ui ) {
                        var data = [];
                        $(".files tr").each(function(){
                            var str = $(".name span",this).text();
Example #14
0
<?php

use yii\helpers\Html;
use dosamigos\fileupload\FileUpload;
use dosamigos\fileupload\FileUploadUI;
use common\models\Advert;
use common\models\File;
use common\models\City;
$this->title = 'Редактирование';
$this->params['breadcrumbs'][] = ['label' => 'Объявления', 'url' => ['/advert/list']];
$this->params['breadcrumbs'][] = ['label' => '№ ' . $model->id, 'url' => ['view', 'id' => $model->id]];
$this->params['breadcrumbs'][] = $this->title;
?>

<?php 
echo $this->render('_form', compact('model', 'directPopulating'));
?>

<?php 
echo FileUploadUI::widget(['model' => new File(), 'attribute' => 'file', 'url' => ['media/upload', 'id' => $model->id], 'gallery' => true, 'fieldOptions' => ['accept' => 'image/*'], 'clientOptions' => ['maxFileSize' => 2000000, 'autoUpload' => true], 'clientEvents' => ['fileuploaddone' => 'function(e, data) {
                console.log(e);
                console.log(data);
            }', 'fileuploadfail' => 'function(e, data) {
                console.log(e);
                console.log(data);
            }']]);
if (Yii::$app->request->isAjax) {
    Yii::$app->view->ignoreCssFile('yii\\bootstrap\\BootstrapAsset', 'css/bootstrap.css');
}
Example #15
0
 /**
  * Initializes the widget.
  */
 public function init()
 {
     if (!$this->model) {
         $this->model = new Media();
     }
     if ($this->ownerModel && !$this->inputContainer) {
         $this->inputContainer = '#' . Html::getInputId($this->ownerModel, $this->ownerModel->getUploadAttribute());
     }
     if ($this->ownerModel && !$this->inputName) {
         $this->inputName = Html::getInputName($this->ownerModel, $this->ownerModel->getUploadAttribute());
     }
     $this->clientOptions = ['autoUpload' => true, 'previewMaxWidth' => 120, 'previewMaxHeight' => 120, 'previewCrop' => true];
     $this->gallery = false;
     if ($this->baseUrl) {
         $this->url = $this->baseUrl . '/upload';
     }
     parent::init();
 }
Example #16
0
use dosamigos\fileupload\FileUploadUI;
/* @var $this yii\web\View */
/* @var $model common\models\Image */
$this->title = 'Создать  Image';
$this->params['breadcrumbs'][] = ['label' => 'Images', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div id="content">
    <div class="outer">
        <div class="inner bg-light lter">
            <div id="collapse4" class="body">
                <div class="image-create">


<?php 
echo FileUploadUI::widget(['model' => $model, 'attribute' => 'name', 'url' => ['/image/create'], 'gallery' => true, 'fieldOptions' => ['accept' => 'image/*'], 'clientOptions' => ['maxFileSize' => 2000000], 'clientEvents' => ['fileuploaddone' => 'function(e, data) {
                                    console.log(e);
                                    console.log(data);
                                }', 'fileuploadfail' => 'function(e, data) {
                                    console.log(e);
                                    console.log(data);
                                }']]);
?>

                </div>
            </div>
        </div>
    </div>
</div>
<?php

use dosamigos\fileupload\FileUploadUI;
use pendalf89\filemanager\Module;
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $searchModel pendalf89\filemanager\models\Mediafile */
?>

<header id="header"><span class="glyphicon glyphicon-upload"></span> <?php 
echo Module::t('main', 'Upload manager');
?>
</header>

<div id="uploadmanager">
    <p><?php 
echo Html::a('← ' . Module::t('main', 'Back to file manager'), ['file/filemanager']);
?>
</p>
    <?php 
echo FileUploadUI::widget(['model' => $model, 'attribute' => 'file', 'clientOptions' => ['autoUpload' => Yii::$app->getModule('filemanager')->autoUpload], 'clientEvents' => ['fileuploadsubmit' => "function (e, data) { data.formData = [{name: 'tagIds', value: \$('#filemanager-tagIds').val()}]; }"], 'url' => ['upload'], 'gallery' => false, 'formView' => '/file/_upload_form']);
?>
</div>
Example #18
0
?>

    <?php 
echo $form->field($model, 'meal_price')->textInput();
?>

    




<?php 
echo FileUploadUI::widget(['name' => 'abc', 'attribute' => 'image', 'url' => ['meal/upload'], 'gallery' => false, 'fieldOptions' => ['accept' => 'image/*'], 'clientOptions' => ['maxFileSize' => 2000000], 'clientEvents' => ['fileuploaddone' => 'function(e, data) {
                                    console.log(e);
                                    console.log(data);
                                }', 'fileuploadfail' => 'function(e, data) {
                                    console.log(e);
                                    console.log(data);
                                }']]);
?>

    <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();
?>
Example #19
0
<?php

use dosamigos\fileupload\FileUploadUI;
use yii\bootstrap\Html;
/**
 * @var integer $maxFileSize
 */
?>

<div class="file-manager-upload">
<?php 
echo Html::a(Yii::t('app', 'Back to file manager'), ['/file/manager/list'], ['class' => 'btn-return']);
echo FileUploadUI::widget(['name' => 'file', 'url' => ['/file/action/upload'], 'gallery' => false, 'clientOptions' => ['maxFileSize' => $maxFileSize]]);
?>
</div>
Example #20
0
<?php

/* @var $this yii\web\View */
$this->title = '上传头像';
use yii\widgets\ActiveForm;
use yii\helpers\Url;
use yii\helpers\Html;
use common\models\Linkage;
use dosamigos\fileupload\FileUploadUI;
?>
<div class="container no-bottom">
    <img class="responsive-image" src="/images/misc/help_server.png" alt="img">
</div>

<div class="container">
    <?php 
echo FileUploadUI::widget(['model' => $model, 'attribute' => 'litpic', 'url' => ['/uploadfile/userpic', 'id' => $model->user_id], 'gallery' => TRUE, 'fieldOptions' => ['accept' => 'image/*'], 'clientOptions' => ['maxFileSize' => 2000000], 'clientEvents' => ['fileuploaddone' => 'function(e, data) {
                console.log(e);
                console.log(data);
                                }', 'fileuploadfail' => 'function(e, data) {
                console.log(e);
                console.log(data);
                                }']]);
?>
</div>
<a href="<?php 
echo Url::toRoute('/member/user/index');
?>
"  style="width:100%;" class="button-big button-red">返回选择图片</a>
<?php

/* @var $this yii\web\View */
use dosamigos\fileupload\FileUploadUI;
?>
    <br/>
<?php 
echo FileUploadUI::widget(['model' => $model, 'attribute' => 'file', 'url' => ['/cms/admin/image/upload', 'model' => $inModel::className(), 'primaryKey' => $primaryKey], 'gallery' => false, 'fieldOptions' => ['accept' => 'image/*'], 'clientOptions' => ['maxNumberOfFiles' => $maxNumberOfFiles]]);
?>

<?php 
if ($fileUploadData) {
    $this->registerJs('
        var $el = $("#image-file-form");
        var e = {
            isDefaultPrevented:function(){return false}
        };
        $el.fileupload("option", "done").call($el, e, {
            result: {files:' . $fileUploadData . '},
        });
    ');
}
Example #22
0
<?php

use dosamigos\fileupload\FileUploadUI;
echo FileUploadUI::widget(['model' => $small, 'attribute' => 'fileUpload', 'url' => ['file-upload/upload'], 'gallery' => false, 'options' => ['id' => 'smallimg'], 'fieldOptions' => ['accept' => 'image/*'], 'clientOptions' => ['maxFileSize' => 2000000], 'clientEvents' => ['fileuploaddone' => 'function(e, data) {
                                    var smallimg = document.getElementById("hotel-smallimg");
                                    smallimg.value = "";
                                    var files = data.result.files;
                                    for(var i = 0; i < files.length; i++){
                                        smallimg.value = files[i].name;
                                    }
                                }', 'fileuploadfail' => 'function(e, data) {
                                    console.log(e);
                                    console.log(data);
                                }']]);