通过 https 从 Dropbox 获取的 PHP 图像损坏
我遇到了一个奇怪的情况,PHP 的工作方式与 HTML 不同。我不是网络程序员,只是闲逛。在 HTML 中,我的图像看起来很好,在 PHP 中,图像被破坏了。只有来自我的 Dropbox https 服务器的公共图像被破坏,来自 http 服务器的图像可以正常工作。
例如,以下是我的本地主机上的两个文件:abc.html 和 def.php。他们尝试显示两张图像,一张指向我的 https 图像,另一张指向 Google 徽标。
abc.html:
<img src='https://photos-1.dropbox.com/i/l/EyvpAUN99vGCmWKqw-ywSYXY1L8dPhkloKA5i9I--NM'>
<img src='http://www.google.co.uk/intl/en_uk/images/logo.gif'>
def.php:
<?php
echo "<img src='https://photos-1.dropbox.com/i/l/EyvpAUN99vGCmWKqw-ywSYXY1L8dPhkloKA5i9I--NM'>";
echo "<img src='http://www.google.co.uk/intl/en_uk/images/logo.gif'>";
exit;
浏览 abc.html 可以完美地显示这两个图像。浏览 def.php 仅显示 Google 徽标,其他图像已损坏。
它不能在 Firefox 上运行,但有人告诉我它可以在 Opera 上运行。
请提出想法:)
编辑:def.php 输出如下:
<img src='https://photos-1.dropbox.com/i/l/EyvpAUN99vGCmWKqw-ywSYXY1L8dPhkloKA5i9I--NM'><img src='http://www.google.co.uk/intl/en_uk/images/logo.gif'>
I have a strange situation with PHP working differently from HTML. I'm not a web programmer, just messing around. In HTML my images appear fine, in PHP the images are broken. And only public images from my Dropbox https server are broken, ones from a http server work.
As an example, here are two files on my localhost, abc.html and def.php. They try to display two images, one pointing to my https image, and another pointing to the Google logo.
abc.html:
<img src='https://photos-1.dropbox.com/i/l/EyvpAUN99vGCmWKqw-ywSYXY1L8dPhkloKA5i9I--NM'>
<img src='http://www.google.co.uk/intl/en_uk/images/logo.gif'>
def.php:
<?php
echo "<img src='https://photos-1.dropbox.com/i/l/EyvpAUN99vGCmWKqw-ywSYXY1L8dPhkloKA5i9I--NM'>";
echo "<img src='http://www.google.co.uk/intl/en_uk/images/logo.gif'>";
exit;
Browsing to abc.html shows both images perfectly. Browsing to def.php only shows the Google logo and the other image is broken.
It doesn't work on Firefox however someone told me it works on Opera.
Ideas please :)
Edit: def.php outputs this:
<img src='https://photos-1.dropbox.com/i/l/EyvpAUN99vGCmWKqw-ywSYXY1L8dPhkloKA5i9I--NM'><img src='http://www.google.co.uk/intl/en_uk/images/logo.gif'>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我建议安装 FireBug 来查看服务器的返回响应是什么。您可能会发现 DropBox 拒绝处理以某些扩展名(例如 .php)结尾的文件的引用的图像请求。
这也可以解释纯 HTTP 的重复行为。
I'd recommend installing FireBug to see what the return response from the server is. You might find that DropBox is refusing to serve requests for images with referrals from files ending with certain extensions, e.g. .php.
This might explain the duplicate behaviour with the plain HTTP too.
这适用于我的 Firefox 3.6 版本,图像显示得非常好:
This works on my Firefox version 3.6, the image shows perfectly well:
试试这个:
如果有效,那是因为 html 属性应该用双引号而不是单引号括起来。也许有些浏览器会原谅这一点,有些则不会。
Try this:
If that works, it's because html attributes should be bounded by double quotes, not single quotes. Perhaps some browsers forgive that and some do not.
这是一个明显的观察结果,但是您的 def.php 是否有结束 php 标签?您的代码示例不...
编辑:将上述内容另存为 html 文件,我在 Chrome 中只看到一张图像...另外 - 您是否安装了 PHP 模块/与您的 Web 服务器关联?
An obvious observation but does your def.php have the closing php tag? Your code example does not...
Edit: Saved the above as a html file, and I only see one image in Chrome... ALSO - Do you have the PHP module installed/associated with your web server?
尝试在两者中“查看源代码”并比较结果。
Try 'view source' in both and compare the results.