|
...
|
...
|
@@ -41,6 +41,15 @@ class ImageController |
|
|
|
$this->path = $this->config['root'].$this->uploads['path'].'/';
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param $hash
|
|
|
|
* @param $w
|
|
|
|
* @param $h
|
|
|
|
* @name :index
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/5/11 17:19
|
|
|
|
*/
|
|
|
|
public function index($hash = '', $w = 0 ,$h = 0 ){
|
|
|
|
if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) || isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
|
|
|
|
header("HTTP/1.1 304 Not Modified");
|
|
...
|
...
|
@@ -58,7 +67,7 @@ class ImageController |
|
|
|
$header = str_replace(['%Expires%', "%etag%", '%Last-Modified%'],
|
|
|
|
[$last_modified_time, $hash . ':' . $w . '_' . $h . '_' . 1, $last_modified_time], $this->upload_img['header']);
|
|
|
|
$content = file_get_contents($filename);
|
|
|
|
$header['Content-Length'] = $info['size'];
|
|
|
|
$header['Content-Length'] = strlen($content);
|
|
|
|
}else{
|
|
|
|
$path = $info['path'];
|
|
|
|
if (!is_file($path)) {
|
|
...
|
...
|
@@ -78,10 +87,7 @@ class ImageController |
|
|
|
}
|
|
|
|
}
|
|
|
|
$header['Content-Type'] = 'image/'.$info['type'];
|
|
|
|
$img_type = $info['type'];
|
|
|
|
$content = base64_encode($content);
|
|
|
|
$img_base64 = 'data:image/' . $img_type . ';base64,' . $content;
|
|
|
|
return response($img_base64,200,$header);
|
|
|
|
return response($content,200,$header);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
...
|
...
|
|