With the following code I display an image (animated gif) in the browser:
header('Content-type:image/gif' );
echo $this->_animatedGif;
I would like to user to be prompted to save the image. I tried
header(sprintf('Content-disposition:attachment;filename=%s', $outputFileName));
echo $this->_animatedGif;
It saves the image directly, without prompting the user to save the file. Using the inline variant
header('Content-disposition:inline');
echo $this->_animatedGif;
doesn't help (as expected.)
Why doesn't Content-disposition:attachment not work with images, but it does work with other file types, like pdf?
Probably saving the file and using HTML attribute 'download' will work, but it's not what I want
<a download="example.gif" href="example.gif">Click here to download the gif file</a>