dtp791357 2015-07-08 18:10
浏览 786
已采纳

将文件移动到其他服务器后,为什么exif_read_data()无法正常工作?

I am attempting to move a program from one server to another and the same script will not work and I can't figure out why...The below is a scaled down version of my script that fails:

<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
$string=file_get_contents("../photos/report14/concreteCurb/baseCompaction1.jpeg");
$exif = exif_read_data("data:image/jpeg;base64," . base64_encode($string));
print_r($exif);
?>

The server that works spits out a simple

Array ( [FileName] => Z [FileDateTime] => 0 [FileSize] => 137976 [FileType] => 2 [MimeType] => image/jpeg [SectionsFound] => COMMENT [COMPUTED] => Array ( [html] => width="773" height="1000" [Height] => 1000 [Width] => 773 [IsColor] => 1 ) [COMMENT] => Array ( [0] => CREATOR: gd-jpeg v1.0 (using IJG JPEG v90), quality = 90 ) )

...but the one that doesn't throws...

Warning: exif_read_data(): Unable to open file in /nfs/c11/h01/mnt/208416/domains/s208416.gridserver.com/html/advantage/scripts/test.php on line 5

Both have EXIF Support enabled (both version 1.4). PHP version on the old server is 5.3.5 whereas the new has 5.5.21, but I also tried it reverted back to 5.3.29 to no avail.

  • 写回答

1条回答 默认 最新

  • dongshanfan1941 2015-07-08 18:30
    关注

    Just a thought, but if you're running this on a CentOS box (might not be directly related to the linux distro) you should try adding the absolute path to the file to the path like this:

    $string = file_get_contents(dirname(__FILE__) . '../photos/report14/concreteCurb/baseCompaction1.jpeg');
    

    This has solved similar problems for me in the past.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部