2

I have tried to open the image in a new tab, but instead of opening it keeps downloading

image src URL comes from DB as it is stored on an s3 bucket

src: "https://****.s3.us-east-2.amazonaws.com/cat_1665033741880.png"

Code:

<a href="<?php echo $image_src?>" target="_blank">Preview</a>

How to open image in new tab?

Vickel
  • 7,879
  • 6
  • 35
  • 56
Emma
  • 79
  • 3
  • 1
    Probably it's about how AWS is bringing the image. It seems someone found the same problem, here is some info: https://stackoverflow.com/questions/14150854/aws-s3-display-file-inline-instead-of-force-download – o1dskoo1 Oct 07 '22 at 08:04
  • thanks but backend is not in my hand, in that case what should I do? – Emma Oct 07 '22 at 08:09
  • Sorry I can not be of more help, I don't work with AWS, but in the post I included there are a couple of solutions (basically, you need to change the images Content-Type) and examples using the AWS SDK for PHP (https://docs.aws.amazon.com/aws-sdk-php/v3/api/index.html). – o1dskoo1 Oct 07 '22 at 09:01
  • 1
    There is a good read on [cross-origin use of images](https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image) – Vickel Oct 08 '22 at 00:56

0 Answers0