简体   繁体   中英

Html - Open a link to a file in browser instead of download

This might be a basic question but I have a link to a file

<a href = "http://sitename.com/path/to/file.jpg">File Name</a>

I want to leave it a link, but when I click it the image just downloads. I would like for it to open in the browser instead of downloading. How can I do this? I feel like this should be easy, but for some reason I can't find the solution.

Your webserver isn't sending the right headers.

If you curl -I http://sitename.com/path/to/file.jpg you should see a header Content-Type .

The correct answer is: Content-Type: image/jpeg

More specific answers are going to depend upon what webserver you're using.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM