[英]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
. 如果您
curl -I http://sitename.com/path/to/file.jpg
,则应该看到标题Content-Type
。
The correct answer is: Content-Type: image/jpeg
正确答案是:
Content-Type: image/jpeg
More specific answers are going to depend upon what webserver you're using. 更具体的答案将取决于您所使用的Web服务器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.