开发者

Broken images in PHP from Dropbox over https

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 to开发者_如何学编程ld 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'>


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.


This works on my Firefox version 3.6, the image shows perfectly well:

<HTML>
<HEAD>
<TITLE>My WebPage</TITLE>
</HEAD>
<BODY>

  <img src="https://photos-1.dropbox.com/i/l/EyvpAUN99vGCmWKqw-ywSYXY1L8dPhkloKA5i9I--NM" />

</BODY>
</HTML>


Try this:

<?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;

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.


An obvious observation but does your def.php have the closing php tag? Your code example does not...

<?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;
?>

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜