0
我有一個函數,顯示上傳到特定網頁的所有文件的列表。我還想顯示文件上次修改的日期,但它顯示的所有日期都是1969年12月31日19:00:00。如何修改此功能以顯示正確的日期? (它在echo語句在結尾):上次修改日期不正確
<?php
foreach($phpfiles as $phpfile)
{
$imageFileType = pathinfo($phpfile,PATHINFO_EXTENSION);
if ($imageFileType == "pdf") {
$faicon = 'fa fa-file-pdf-o';
} else if ($imageFileType == "doc" || $imageFileType == "docx") {
$faicon = 'fa fa-file-word-o';
} else if ($imageFileType == "xls" || $imageFileType == "xlsx") {
$faicon = 'fa fa-file-excel-o';
} else if ($imageFileType == "ppt" || $imageFileType == "pptx") {
$faicon = 'fa fa-file-powerpoint-o';
} else if ($imageFileType == "mp4") {
$faicon = 'fa fa-file-video-o';
} else if ($imageFileType == "jpg" || $imageFileType == "png" || $imageFileType == "gif" || $imageFileType == "bmp") {
$faicon = 'fa fa-file-image-o';
} else {
$faicon = 'fa fa-file-text-o';
}
if ($server_name <> ""){
$phpfile = "http://". $server_name . '/' .$phpfile;
}
echo "<span class='$faicon w3-large'></span>  <a href='$phpfile' class='w3-medium' target='_blank'>".substr(basename($phpfile),-1*strlen(basename($phpfile))+strlen($id)+1)."</a> ". date("F d Y H:i:s.", filemtime($phpfile));
}
?>
你檢查這https://stackoverflow.com/questions/1853575/why-do-i-get-31-dec-1969-as-my-last-modified-filename-using-filemtime-在-php –
我沒有,但在閱讀它後,我沒有得到任何錯誤建議。此外,我的文件正在填充,所以我知道它正在查找該文件。 – xxdash
這會迴應'''file_exists($ phpfile)'''?要求根據你當前的代碼$ phpfile可能是有效的位置,所以pathinfo()將正常工作(它does not檢查存在的文件,只是解析字符串,因爲我記得),但沒有什麼會在文件系統 –