|
@@ -41,6 +41,15 @@ class ImageController |
|
@@ -41,6 +41,15 @@ class ImageController |
|
41
|
$this->path = $this->config['root'].$this->uploads['path'].'/';
|
41
|
$this->path = $this->config['root'].$this->uploads['path'].'/';
|
|
42
|
}
|
42
|
}
|
|
43
|
|
43
|
|
|
|
|
44
|
+ /**
|
|
|
|
45
|
+ * @param $hash
|
|
|
|
46
|
+ * @param $w
|
|
|
|
47
|
+ * @param $h
|
|
|
|
48
|
+ * @name :index
|
|
|
|
49
|
+ * @author :lyh
|
|
|
|
50
|
+ * @method :post
|
|
|
|
51
|
+ * @time :2023/5/11 17:19
|
|
|
|
52
|
+ */
|
|
44
|
public function index($hash = '', $w = 0 ,$h = 0 ){
|
53
|
public function index($hash = '', $w = 0 ,$h = 0 ){
|
|
45
|
if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) || isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
|
54
|
if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) || isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
|
|
46
|
header("HTTP/1.1 304 Not Modified");
|
55
|
header("HTTP/1.1 304 Not Modified");
|
|
@@ -58,7 +67,7 @@ class ImageController |
|
@@ -58,7 +67,7 @@ class ImageController |
|
58
|
$header = str_replace(['%Expires%', "%etag%", '%Last-Modified%'],
|
67
|
$header = str_replace(['%Expires%', "%etag%", '%Last-Modified%'],
|
|
59
|
[$last_modified_time, $hash . ':' . $w . '_' . $h . '_' . 1, $last_modified_time], $this->upload_img['header']);
|
68
|
[$last_modified_time, $hash . ':' . $w . '_' . $h . '_' . 1, $last_modified_time], $this->upload_img['header']);
|
|
60
|
$content = file_get_contents($filename);
|
69
|
$content = file_get_contents($filename);
|
|
61
|
- $header['Content-Length'] = $info['size'];
|
70
|
+ $header['Content-Length'] = strlen($content);
|
|
62
|
}else{
|
71
|
}else{
|
|
63
|
$path = $info['path'];
|
72
|
$path = $info['path'];
|
|
64
|
if (!is_file($path)) {
|
73
|
if (!is_file($path)) {
|
|
@@ -78,10 +87,7 @@ class ImageController |
|
@@ -78,10 +87,7 @@ class ImageController |
|
78
|
}
|
87
|
}
|
|
79
|
}
|
88
|
}
|
|
80
|
$header['Content-Type'] = 'image/'.$info['type'];
|
89
|
$header['Content-Type'] = 'image/'.$info['type'];
|
|
81
|
- $img_type = $info['type'];
|
|
|
|
82
|
- $content = base64_encode($content);
|
|
|
|
83
|
- $img_base64 = 'data:image/' . $img_type . ';base64,' . $content;
|
|
|
|
84
|
- return response($img_base64,200,$header);
|
90
|
+ return response($content,200,$header);
|
|
85
|
}
|
91
|
}
|
|
86
|
|
92
|
|
|
87
|
/**
|
93
|
/**
|