Benjamin Thvedt
Benjamin Thvedt

Reputation: 351

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.

Upvotes: 0

Views: 2151

Answers (1)

Corey Quinn
Corey Quinn

Reputation: 66

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.

Upvotes: 2

Related Questions