How to show an image which is secured by http authentication

user3053216 picture user3053216 · Jun 4, 2014 · Viewed 10.5k times · Source

How can i show an image from a server with standard http protection without showing the authentication window?

I now use standard html

<img src="...">

but because the image is protected this asks for an authentication window. I do have the login data, how can i show the image?

Regards, Tom.

Answer

Brobin picture Brobin · Jun 4, 2014

This should work. Simply replace the username and password with your authentication details. (Warning: Doesn't work in all browsers)

<img src="http://username:password@server/Path" />

I would recommend putting this in a separate file on your server. That way you can reference it without exposing the authentication info.