开发者

External images not showing under apache

开发者 https://www.devze.com 2023-04-10 20:29 出处:网络
I have two virtual systems for development. First one is Windows + xampp (apache, php, mysql) and second one is Linux + apache + php + mysql. I have very very simple page that loads images from databa

I have two virtual systems for development. First one is Windows + xampp (apache, php, mysql) and second one is Linux + apache + php + mysql. I have very very simple page that loads images from database (yes, images are in the database not on the filesystem, it is not the case here, is it right or not) using external links.

The first page shows photos:

<img src="photo.php?photo_id=4" height="127" width="127">

The second page loads them from database:

if (isset($_GET['photo_id'])) {
    $link = getDBconnection();
   开发者_运维问答 $result = getPhoto($link, $_GET['photo_id']);

    if ($result) {
        $row = mysql_fetch_assoc($result);
        header("Content-type: " . $row['MIMEtype']);
        echo $row['photoImage'];
    }

    closeDBconnection($link);
}

Everything is working fine on the Windows machine but on the linux machine, pictures just don't show up. I mean image files from page directory loads up and shows up but somehow this external link stopped working. I've places few echos and for sure script executes and photoImage has binary data.

I wonder, is it just configuration issue (probable, am not configuring apache/php/mysql every day). I've stuck at that point. Any ideas?

PS. Database is exactly the same. I've just exported/imported it from Windows to Linux mysql database. Any other data is successfully selected from database. It's just the photos, that don't work.

SOLVED

Thanks Marc B for the tip about encoding. I was aware of the possible issue but completely forgot about it. After copying the files once more time to the LINUX machine via ftp, and after double checking that I did not change encoding (by editing any file), the photos showed up.


Some things to check:

  1. Check for database errors - you say the photoImage field has binary data, so not likely, but never ever assume a database call succeeded
  2. Check for early text output, causing the header() call to fail - it should be getting logged somewhere. Turn on display_errors/error_logging while developing, in any case, so you don't have to rummage around in logs to find out what's going wrong.
  3. Hit the url manually in a browser and see what comes through. Perhaps there's some characterset translation going causing the image data to be corrupted (e.g. you're using a TEXT field instead of a BLOB).
0

精彩评论

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

关注公众号