Email Id : phpmk888@gmail.com
1. Create Extension in yii2.
> in short : go to @app/vendor/yourname
2. create Your Extension Directory : mk-zip/zip/ create file name
FileZip.php
<?php
namespace zip\file;
use Yii;
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use kartik\base\InputWidget;
use kartik\base\TranslationTrait;
use yii\web\UploadedFile;
class FileZip extends InputWidget
{
public function init()
{
parent::init();
}
public function uploadZip() {
return 'Mahehs Kathiruya';
}
public function upload($model)
{
if ($model->validate()) {
$model->imageFile->saveAs('uploads/' . $model->imageFile->baseName . '.' . $model->imageFile->extension);
return true;
} else {
return false;
}
}
}
?>
3. create composer.json
{
"name": "mk-zip/",
"description": "An enhanced FileInput widget for Bootstrap 3.x with file preview, multiple selection, and more features (sub repo split from yii2-widgets)",
"keywords": ["yii2", "extension", "widget", "input", "file", "form", "upload", "jquery", "plugin"],
"homepage": "",
"type": "yii2-extension",
"license": "BSD-3-Clause",
"authors": [
{
"name": "Mahesh Kathiriya",
"email": "phpmk888@gmail.com",
"homepage": ""
}
],
"autoload": {
"psr-4": {
"zip\\file\\": ""
}
},
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
}
}
4. Go to Main Composer.json file open add "mk-zip/zip":"*" in Require
5. go to yiisoft open extentions.php add
'mk-zip/zip' =>
array(
'name' => 'mk-zip/zip',
'version' => '9999999-dev',
'alias' =>
array(
'@zip/file' => $vendorDir . '/mk-zip/zip',
),
),
6. call zip extention in front end
use zip\file\FileZip;
FileZip::uploadZip();
Wonderful blog & good post.Its really helpful for me, awaiting for more new post. Keep Blogging!
ReplyDeleteHire Yii Framework Development Company in India