2017 © Pedro Peláez
 

yii2-extension yii2-upload-from-url

UploadFromUrl extension for Yii Framework 2

image

igogo5yo/yii2-upload-from-url

UploadFromUrl extension for Yii Framework 2

  • Tuesday, January 16, 2018
  • by igogo5yo
  • Repository
  • 4 Watchers
  • 3 Stars
  • 7,287 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 5 Forks
  • 0 Open issues
  • 7 Versions
  • 14 % Grown

The README.md

UploadFromUrl extension for Yii 2

Build Status Latest Stable Version Total Downloads License Dependency Status codecov.io, (*1)

This is the upload file from url address extension for Yii 2. It have class UploadFromUrl for upload files from URL and it have FileFromUlrValidator for validate model attribute with file from url., (*2)

Please submit issue reports and pull requests to the main repository. For license information check the LICENSE-file., (*3)

Installation

The preferred way to install this extension is through composer., (*4)

Either run, (*5)

php composer.phar require --prefer-dist igogo5yo/yii2-upload-from-url

or add, (*6)

"igogo5yo/yii2-upload-from-url": ">=1.0"

to your composer.json file, (*7)

Usage

Example 1, (*8)

$model = new Post();
$model->load(Yii::$app->request->post());

$file = UploadFromUrl::getInstance($model, 'image');

//if second parameter is TRUE it writes uploaded file path to this model property
$file->saveAs('uploads/yii.png', true);   

echo $model->image; // uploads/yii.png

Example 2, (*9)

$model = new Post();
$model->image = 'http://static.yiiframework.com/files/logo/yii.png';

$file = UploadFromUrl::initWithModel($model, 'image');

//if second parameter is TRUE it writes uploaded file path to this model property
$file->saveAs('uploads/yii.png', true);   

echo $model->image; // uploads/yii.png

Example 3, (*10)

$url = 'http://static.yiiframework.com/files/logo/yii.png' ;
$path = 'uploads/yii.png';

$file = UploadFromUrl::initWithUrl($url);
$file->saveAs($path);   

//Set to model
$model = new Post();
$model->image = $path;

Example 4, (*11)

$url = 'http://static.yiiframework.com/files/logo/yii.png' ;
$path = 'uploads/yii.png';
$model = new Post();

$file = UploadFromUrl::initWithUrlAndModel($url, $model, 'image');
$file->saveAs($path, true);   

echo $model->image; // uploads/yii.png

Validation Example, (*12)

[
...
     [['image'], 'igogo5yo\uploadfromurl\FileFromUrlValidator', 'extensions' => 'csv', 'mimeTypes' => 'text/plain'],
...
]

Run Tests

phpunit --bootstrap tests/bootstrap.php tests

The Versions

16/01 2018

dev-master

9999999-dev

UploadFromUrl extension for Yii Framework 2

  Sources   Download

MIT

The Requires

 

The Development Requires

by Skliar Ihor

framework yii2 upload file igogo5yo upload link upload url

16/01 2018

v1.4

1.4.0.0

UploadFromUrl extension for Yii Framework 2

  Sources   Download

MIT

The Requires

 

The Development Requires

by Skliar Ihor

framework yii2 upload file igogo5yo upload link upload url

26/06 2017

v1.3

1.3.0.0

UploadFromUrl extension for Yii Framework 2

  Sources   Download

MIT

The Requires

 

The Development Requires

by Skliar Ihor

framework yii2 upload file igogo5yo upload link upload url

22/11 2015

v1.2

1.2.0.0

UploadFromUrl extension for Yii Framework 2

  Sources   Download

MIT

The Requires

 

The Development Requires

by Skliar Ihor

framework yii2 upload file igogo5yo upload link upload url

26/09 2015

1.1

1.1.0.0

UploadFromUrl extension for Yii Framework 2

  Sources   Download

MIT

The Requires

 

by Skliar Ihor

framework yii2 upload file igogo5yo upload link upload url

29/05 2015

v1.0

1.0.0.0

UploadFromUrl extension for Yii Framework 2

  Sources   Download

MIT

The Requires

 

by Skliar Ihor

framework yii2 upload file igogo5yo upload link upload url

29/05 2015

1.0

1.0.0.0

UploadFromUrl extension for Yii Framework 2

  Sources   Download

MIT

The Requires

 

by Skliar Ihor

framework yii2 upload file igogo5yo upload link upload url