我試圖打開連接到不同用戶名的目錄中的最新文件。然而,一些用戶名沒有上傳目錄,我想跳過這些用戶或創建目錄無論哪一個。這是我現在的代碼。如果目錄不存在,跳過或製作目錄php
<?php $path = base_url(''.$value['username']) . '/' . 'uploaded';)
$latest_ctime = 0;
$latest_filename = '';
$d = dir($path);
while (false !== ($entry = $d->read())) {
$filepath = "{$path}/{$entry}";
// could do also other checks than just checking whether the entry is a file
if (is_file($filepath) && filectime($filepath) > $latest_ctime) {
$latest_ctime = filectime($filepath);
$latest_filename = $entry;
}
}?>
當我上傳此我得到的錯誤是
A PHP Error was encountered
Severity: Warning
Message: dir(https://www.domain.com/pdfs/bob/uploaded): failed to open dir: not implemented
Filename: views/search.php
Line Number: 71
我試圖尋找並嘗試了一些東西的mkdir我發現,沒有工作。即使是我在stackoverflow上找到的最新文件。
你還沒有在代碼中做任何目錄或檢查是否存在目錄 – soni8010