PHP code example of boliver20 / yii2-dropzone

1. Go to this page and download the library: Download boliver20/yii2-dropzone library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

boliver20 / yii2-dropzone example snippets


echo \boliver\DropZone::widget();

echo \boliver\DropZone::widget([
       'options' => [
           'maxFilesize' => '2',
       ],
       'clientEvents' => [
           'complete' => "function(file){console.log(file)}",
           'removedfile' => "function(file){alert(file.name + ' is removed')}"
       ],
   ]);

public function actionUpload()
{
    $fileName = 'file';
    $uploadPath = './files';

    $file = \yii\web\UploadedFile::getInstanceByName($fileName);

    //Print file data
    //print_r($file);

    if ($file && $file->saveAs($uploadPath . '/' . $file->name)) {
        //Now save file data to database

        echo \yii\helpers\Json::encode($file);
    }

    return false;
}

php composer.phar