UPLOAD FILES IN YII 2 USING KARTIK FILEINPUT

 


 

Source: https://code.tutsplus.com/tutorials/how-to-program-with-yii2-uploading-files–cms-23511

There are two file upload plugins for Yii2 that seem the most robust:

  1. The FileInput Widget by Kartik Visweswaran (shown above)
  2. The 2Amigos BlueImp File Uploader (a wrapper for the BlueImp JQuery File Uploader

For this tutorial, I decided to continue with Kartik's plugin. I found it easier to use and better documented than the 2Amigos plugin. However, the BlueImp File Uploader has some intriguing user experience features that you may want to explore (shown below):

Yii2 Image Uploads - 2Amigos and BlueImp File Upload Examples

Working With the FileInput Plugin

Let's begin to install and make use of the file uploader and integrate it into our Twitter-like status creation applet. Again, we'll use the Yii2 Hello application tree which you can download with the GitHub button link beside or below.

Installing the Plugin

First, we can use composer to add kartik-v/yii2-widget-fileinput to our application:

1
$ composer require kartik-v/yii2-widget-fileinput "*"
2
./composer.json has been updated
3
Loading composer repositories with package information
4
Updating dependencies (including require-dev)
5
  - Updating kartik-v/yii2-widget-fileinput (dev-master 36f9f49 => v1.0.4)
6
    Checking out 36f9f493c2d814529f2a195422a8af2e020fc80c
7

8
Writing lock file
9
Generating autoload files

There are two file upload plugins for Yii2 that seem the most robust:

  1. The FileInput Widget by Kartik Visweswaran (shown above)
  2. The 2Amigos BlueImp File Uploader (a wrapper for the BlueImp JQuery File Uploader

For this tutorial, I decided to continue with Kartik's plugin. I found it easier to use and better documented than the 2Amigos plugin. However, the BlueImp File Uploader has some intriguing user experience features that you may want to explore (shown below):

Yii2 Image Uploads - 2Amigos and BlueImp File Upload Examples

Working With the FileInput Plugin

Let's begin to install and make use of the file uploader and integrate it into our Twitter-like status creation applet. Again, we'll use the Yii2 Hello application tree which you can download with the GitHub button link beside or below.

Installing the Plugin

First, we can use composer to add kartik-v/yii2-widget-fileinput to our application:

1
$ composer require kartik-v/yii2-widget-fileinput "*"
2
./composer.json has been updated
3
Loading composer repositories with package information
4
Updating dependencies (including require-dev)
5
  - Updating kartik-v/yii2-widget-fileinput (dev-master 36f9f49 => v1.0.4)
6
    Checking out 36f9f493c2d814529f2a195422a8af2e020fc80c
7

8
Writing lock file
9
Generating autoload files


Post a Comment

0 Comments