Add Content-Disposition to make saving images cleaner

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.
This commit is contained in:
Chip Wasson 2016-08-29 11:08:12 -06:00
parent 4abd000917
commit 745b9cc692

View File

@ -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);
}