【发布时间】:2018-12-12 09:49:53
【问题描述】:
我有一个使用 Python 的 image.asp 文件,我试图在其中打开一个 JPEG 图像并将其写入响应,以便可以从相关链接中检索它。我目前拥有的:
<%@ LANGUAGE = Python%>
<%
path = "path/to/image.jpg"
with open(path, 'rb') as f:
jpg = f.read()
Response.ContentType = "image/jpeg"
Response.WriteBinary(jpg)
%>
在浏览器中,这会返回以下错误:
The image "url/to/image.asp" cannot be displayed because it contains errors.
我怀疑问题是我没有正确写入 jpg 文件的内容。我需要解决什么问题?
【问题讨论】:
-
您是否尝试过使用不同的文件来测试它不是损坏的 image.asp?
-
@Puffycheeses 怎么会坏呢?
-
可以添加
curl -v <url>的输出