Total Complexity | 15 |
Total Lines | 43 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
3 | class Nip_File_Upload extends Nip_File |
||
4 | { |
||
5 | protected $_error; |
||
6 | protected $_tmp_name; |
||
7 | |||
8 | public function __construct($data = []) |
||
15 | } |
||
16 | } |
||
17 | |||
18 | public function valid() |
||
19 | { |
||
20 | $result = false; |
||
21 | |||
22 | $max_upload = ini_get('post_max_size'); |
||
23 | $unit = strtoupper(substr($max_upload, -1)); |
||
24 | $multiplier = ($unit == 'M') ? 1048576 : (($unit == 'K') ? 1024 : (($unit == 'G') ? 1073741824 : 1)); |
||
25 | |||
26 | if ($max_upload && ((int) $_SERVER['CONTENT_LENGTH'] > $multiplier * (int) $max_upload)) { |
||
27 | return self::ERROR_MAX_POST_SIZE; |
||
28 | } |
||
29 | |||
30 | if (!$this->getPath()) { |
||
31 | return false; |
||
32 | } elseif (isset($this->error) && $this->error != 0) { |
||
33 | return false; |
||
34 | } elseif (!isset($this->_tmp_name) || !@is_uploaded_file($this->_tmp_name)) { |
||
35 | return false; |
||
36 | } elseif (!isset($this->_name)) { |
||
37 | return false; |
||
38 | } |
||
39 | |||
40 | return true; |
||
41 | } |
||
42 | |||
43 | public function upload($path) |
||
46 | } |
||
47 | } |
||
48 |