0

I have an Ubuntu Apache server with Mautic installed, which allows to upload images and files, and then link them in emails etc.

When I upload a pdf and then open the link to it - it opens in browser. When I upload a jpg or gif file - it forces download...

I tried to add the following to the .htaccess in the files folder, and it did nothing:

<IfModule mod_headers.c>
  <FilesMatch "\.jpg$">
      Header append Content-Disposition "inline"
      Header set Content-Type "image/png"
  </FilesMatch>
</IfModule>

How can I allow the browser to show the images in it, without downloading?

Thanks

omer
  • 1
  • Are you uploading to the media/images folder? That appears to [have a .htaccess](https://github.com/mautic/mautic/blob/staging/media/images/.htaccess) that removes handlers for specific (script) file types, and then explicitly sets `None` and `default-handler` for everything served from that directory. Simply removing it completely might be dangerous (if a script file ever gets uploaded to that folder somehow, it might get executed), but perhaps the appropriate handlers/types could specifically be added again for image types. – 04FS Apr 03 '19 at 09:57
  • The files are uploaded to the media/files folder, and the .htaccess file there contains only 'deny from all'... – omer Apr 04 '19 at 13:06

1 Answers1

0

I found a solution - edited the the php file that calls the assets so that he will call them with 'inline' instead of 'attachment' (mautic/app/bundles/AssetBundle/Controller/PublicController.php):

if (!$stream) {
  $response->headers->set('Content-Disposition', 'attachment;filename="'.$entity->getOriginalFileName());
}

changed to

if (!$stream) {
  $response->headers->set('Content-Disposition', 'inline;filename="'.$entity->getOriginalFileName());
}

Perhaps there is also a way to workaround this without editing the code (some .htaccess rules maybe?), if someone knows how it will be great to know.

omer
  • 1