Php 脚本无法从目录中读取文件

Php 脚本无法从目录中读取文件,php,exif,Php,Exif,我有一个脚本,它从存储在给定目录中的照片中提取Exif数据,然后在网页上显示包含Exif信息的图像 以下是脚本中检索exif数据的部分,此示例为硬编码图像: $Image = 'original/raleighbike.JPG'; echo "$Image"; $exif = exif_read_data($Image, 0, true); 这将起作用,并显示exif数据。 (echo只是为了验证下一部分中的检索设置是否正确,这就是我遇到的问题。) 现在,我使用相同

我有一个脚本,它从存储在给定目录中的照片中提取Exif数据,然后在网页上显示包含Exif信息的图像

以下是脚本中检索exif数据的部分,此示例为硬编码图像:

    $Image = 'original/raleighbike.JPG';

    echo "$Image";

    $exif = exif_read_data($Image, 0, true);
这将起作用,并显示exif数据。 (echo只是为了验证下一部分中的检索设置是否正确,这就是我遇到的问题。)

现在,我使用相同的脚本从先前脚本中上传并存储在同一目录中的图像获取exif。 上载脚本设置一个包含图像名称和位置的变量($Image9),exif提取脚本现在如下所示:

$Image = $Image9;

echo "$Image";

$exif = exif_read_data($Image, 0, true);
我遇到的问题是,“echo”打印正确的图像名称和位置,但exif数据为空,错误日志显示:

[02-Apr-2013 18:45:29 America/Chicago] PHP Warning:  exif_read_data() [<a href='function.exif-read-data'>function.exif-read-data</a>]: Unable to open file in /home2/webi8726/public_html/domain.com/sqlsidebar/displayexif.php on line 23
生成的回显字符串显示以下内容

original/raleighbike.jpg - content of variable $photo (correct)
original/raleighbike.jpg - content of variable $Image (correct)
image file not found - when checking for the file in $Image (incorrect, file does exist)
photo file not found - when checking for the file in $photo (incorrect, file does exist)
thumb file not found - when checking for the file in $thumb (incorrect, file does exist)
thumbnail/thumb_raleighbike.jpg
因此,如果一个文件是硬编码的,那么脚本可以物理定位它,但是如果一个文件被指定为变量,那么脚本就找不到它们


有人知道为什么会发生这种情况吗?我肯定不是唯一一个经历过这个问题的人-(

您的代码是
$Image9
,但您的描述是
$Image99
。是哪一个?设置后,您是否进行了基本调试以查看
$Image
的内容?抱歉-输入错误-它是$Image9。当您说调试时,我输入了“echo”以打印$Image的内容,在这两种情况下(硬编码和变量)详细信息是正确的-即指向正确的位置/图像。让我感到困惑的是,为什么“exif_read_data”无法访问目录/图像,而硬编码指令却可以。包含在
$Image9
中的路径是相对的还是绝对的?是否检查了文件权限?我已检查了图像目录-7上的文件权限77.显示的硬编码和变量路径相同='original/image.jpg',文件本身的权限也正确吗?
original/raleighbike.jpg - content of variable $photo (correct)
original/raleighbike.jpg - content of variable $Image (correct)
image file not found - when checking for the file in $Image (incorrect, file does exist)
photo file not found - when checking for the file in $photo (incorrect, file does exist)
thumb file not found - when checking for the file in $thumb (incorrect, file does exist)
thumbnail/thumb_raleighbike.jpg