简体   繁体   English

HTML-在浏览器中打开指向文件的链接,而不是下载

[英]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.

相关问题 打开文件而不是链接而不是下载 - open the file instead of the link and not to download 如何强制下载.csv文件,而不是在html中的浏览器上打开 - How to forcefully download .csv file instead of getting in open on browser in html 强制浏览器打开文件而不是提示下载 - Force browser to open file instead of prompting download 如何创建下载链接以下载文件而不是重定向到浏览器? - How to create download link to download a file instead of redirecting to browser? HTML标头:打开文件而不是下载文件 - Html Header: Open file instead of download it html 下载链接打开新的浏览器页面而不是启动下载 - 链接不起作用? - html download link opens new browser page instead of initiating download - link not working? 创建的下载链接打开链接而不是下载它 - the created download link to open the link instead of downloading it (HTML) 下载 PDF 文件,而不是单击时在浏览器中打开它们 - (HTML) Download a PDF file instead of opening them in browser when clicked 如何强制下载文件提示而不是使用 HTML 在浏览器中显示? - How to force a Download File prompt instead of displaying it in-browser with HTML? 在 html 锚链接上下载音频文件,单击独立于浏览器操作 - Download audio file on html anchor link click independant of browser action
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM