我正在尝试使用filemtime
获取一些文件的最后修改日期和时间。不幸的是,所有文件都无法获取。我已经尝试使用完整路径(例如www.mysite.com/images/file.png),也尝试仅使用扩展名(例如/images/file.png)以及仅使用文件名本身(file.png)。但是没有任何效果。请问如何传递路径引用以便找到我的文件?谢谢!
<br />n<b>Warning</b>: filemtime() [<a href='function.filemtime'>function.filemtime</a>]: stat failed for www.mysite.com/images/hills.png in <b>D:\Hosting\11347607\html\mobile\updateImages.php</b> on line <b>20</b><br
这是PHP脚本:
<?php
include '../scripts/connection.php';
//get information on this location from the database
$sql = "SELECT * FROM types";
$result = mysql_query($sql);
$array = array();
while ($row = mysql_fetch_array($result)) {
$path = $row['path'] . $row['picture_url'];
$last_mod = filemtime($path);
$this_file = array(
'filename' => $row['picture_url'],
'last_mod' => $last_mod
);
$array[$row['type']] = $this_file;
}
echo json_encode(array('result'=>'success', 'message'=>$array));
?>
$path
是什么吗?你有从PHP以外的其他方式检查过该路径是否真的存在吗?如果它确实存在,则请检查PHP运行的任何用户是否具有写入访问该目录树和文件的权限。 - Marc B