forked from 2amigos/yii2-file-upload-widget
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBaseUpload.php
55 lines (49 loc) · 1.44 KB
/
BaseUpload.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
/**
* @copyright Copyright (c) 2013 2amigOS! Consulting Group LLC
* @link http://2amigos.us
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
*/
namespace dosamigos\fileupload;
use yii\base\InvalidConfigException;
use yii\helpers\Url;
use yii\widgets\InputWidget;
/**
* BaseUpload
*
* Base class for both uploaders.
* @author Antonio Ramirez <[email protected]>
* @link http://www.ramirezcobos.com/
* @link http://www.2amigos.us/
* @package dosamigos\fileupload
*/
class BaseUpload extends InputWidget
{
/**
* @var string|array upload route
*/
public $url;
/**
* @var array the plugin options. For more information see the jQuery File Upload options documentation.
* @see https://github.com/blueimp/jQuery-File-Upload/wiki/Options
*/
public $clientOptions = [];
/**
* @var array the event handlers for the jQuery File Upload plugin.
* Please refer to the jQuery File Upload plugin web page for possible options.
* @see https://github.com/blueimp/jQuery-File-Upload/wiki/Options#callback-options
*/
public $clientEvents = [];
/**
* @inheritdoc
* @throws \yii\base\InvalidConfigException
*/
public function init()
{
parent::init();
if(empty($this->url)) {
throw new InvalidConfigException('"url" cannot be empty.');
}
$this->clientOptions['url'] = Url::to($this->url);
}
}