From 745b9cc692c93618573d2cd7d5ff25ac8a5fdbc1 Mon Sep 17 00:00:00 2001 From: Chip Wasson Date: Mon, 29 Aug 2016 11:08:12 -0600 Subject: [PATCH] Add Content-Disposition to make saving images cleaner MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a user tries to save a file from the browser, make the filename the url they entered so they don’t have to type it again. --- http2pic.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/http2pic.class.php b/http2pic.class.php index 79a6254..96aca94 100644 --- a/http2pic.class.php +++ b/http2pic.class.php @@ -231,11 +231,13 @@ class http2pic if ($this->params['type'] === 'png') { header('Content-Type: image/png'); + header('Content-Disposition: inline; filename="'.$this->trimToAlphaNumeric($this->params['url']).'"'); $result = imagecreatefrompng($this->params['file']); imagepng($result, NULL, 9); } else { header('Content-Type: image/jpeg'); + header('Content-Disposition: inline; filename="'.$this->trimToAlphaNumeric($this->params['url']).'"'); $result = imagecreatefromjpeg($this->params['file']); imagejpeg($result, NULL, 100); }