|
@@ -163,35 +163,41 @@ class Core
|
|
|
*/
|
|
|
private function check_size()
|
|
|
{
|
|
|
- if (!$this->limit && !$this->base64 && ($this->ext == '.jpg' || $this->ext == '.gif' || $this->ext == '.png') && is_file($this->data['file']['tmp_name'])) {
|
|
|
- $this->limit = @getimagesize($this->data['file']['tmp_name']);
|
|
|
+ if (!$this->limit && !$this->base64 && ($this->ext == '.jpg' || $this->ext == '.gif' || $this->ext == '.png') && !strstr($this->data['file']['tmp_name'], 'http')) {
|
|
|
+ $this->limit = getimagesize($this->data['file']['tmp_name']);
|
|
|
}
|
|
|
|
|
|
+ if (isset($this->data['file']['size'])) {
|
|
|
+ $this->size = $this->data['file']['size'];
|
|
|
+ $this->limit();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ protected function limit()
|
|
|
+ {
|
|
|
|
|
|
$size = $this->config['size'] > 0 ? 1024*1024*$this->config['size'] : 30*1024*1024;
|
|
|
|
|
|
- if (isset($this->data['file']['size'])) {
|
|
|
- $this->size = $this->data['file']['size'];
|
|
|
-
|
|
|
- if (($size < $this->data['file']['size']) && $size > 0) {
|
|
|
- $this->output['status'] = -1;
|
|
|
- $this->output['message'] = '文件不能超过'.(($size/1024)/1024).'MB';
|
|
|
- } elseif ($this->limit && isset($this->config['setwh']) && $this->config['setwh'] == 2 && $this->limit[0] < $this->limit[1]) {
|
|
|
+ if (($size < $this->size) && $size > 0) {
|
|
|
+ $this->output['status'] = -1;
|
|
|
+ $this->output['message'] = '文件不能超过'.$this->config['size'].'MB';
|
|
|
+ } elseif ($this->limit) {
|
|
|
+ if (isset($this->config['setwh']) && $this->config['setwh'] == 2 && $this->limit[0] < $this->limit[1]) {
|
|
|
$this->output['status'] = -1;
|
|
|
$this->output['message'] = '图片高度不能超过图片宽度';
|
|
|
- } elseif ($this->limit && isset($this->config['setwh']) && $this->config['setwh'] == 3 && $this->limit[0] > $this->limit[1]) {
|
|
|
+ } elseif (isset($this->config['setwh']) && $this->config['setwh'] == 3 && $this->limit[0] > $this->limit[1]) {
|
|
|
$this->output['status'] = -1;
|
|
|
$this->output['message'] = '图片宽度不能超过图片高度';
|
|
|
- } elseif ($this->limit && $this->config['width'] > 0 && $this->config['width'] < $this->limit[0]) {
|
|
|
+ } elseif ($this->config['width'] > 0 && $this->config['width'] > $this->limit[0]) {
|
|
|
$this->output['status'] = -1;
|
|
|
- $this->output['message'] = '图片宽度不能超过' . $this->config['width'] . 'px';
|
|
|
- } elseif ($this->limit && $this->config['height'] > 0 && $this->config['height'] < $this->limit[1]) {
|
|
|
+ $this->output['message'] = '图片宽度不能小于' . $this->config['width'] . 'px';
|
|
|
+ } elseif ($this->config['height'] > 0 && $this->config['height'] > $this->limit[1]) {
|
|
|
$this->output['status'] = -1;
|
|
|
- $this->output['message'] = '图片高度不能超过' . $this->config['height'] . 'px';
|
|
|
+ $this->output['message'] = '图片高度不能小于' . $this->config['height'] . 'px';
|
|
|
}
|
|
|
-
|
|
|
- $this->size = number_format($this->size/1024, 2);
|
|
|
}
|
|
|
+
|
|
|
+ $this->size = number_format($this->size/1024, 2);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -260,7 +266,9 @@ class Core
|
|
|
$this->ext = '.jpg';
|
|
|
}
|
|
|
if (!isset($file)) {
|
|
|
- Dever::alert('错误的文件来源');
|
|
|
+ $this->output['status'] = -1;
|
|
|
+ $this->output['message'] = '错误的文件来源';
|
|
|
+ return $this->output;
|
|
|
}
|
|
|
$state = file_put_contents($this->data['file']['tmp_name'], $file);
|
|
|
if (!$state) {
|