私の質問には 2 つの部分があります。
1- ディレクトリD:/wamp/www/test/gmail-imap/upload/
とそれに含まれる 5 つのファイルがあります。このディレクトリを次のように読み取る必要があります。
ini_set('display_errors',1);
$dir = "D:/wamp/www/test/gmail-imap/upload/";
$i=0;
// Open a directory, and read its contents
if (is_dir($dir)){
if ($dh = opendir($dir)){
while (($file = readdir($dh)) !== false){
if($file!=''){
echo $i."-filename:" . $file . "<br>"; $i++;
}
}
closedir($dh);
}
}
die();
出力したのがこれ
0-filename:.
1-filename:..
2-filename:1-stackoverflow.png
3-filename:2-stackoverflow.png
4-filename:3-Desert.jpg
5-filename:4-code.zip
6-filename:5-Chapter13.pdf
私の出力には 0 と 1 は必要ありません。
http://localhost/test/gmail-imap/uploads
2-代わりにサーバーから読み取る必要がありますD:/wamp/www/test/gmail-imap/upload/
なにか提案を?
最初の部分は次のように修正されます
ini_set('display_errors',1);
$dir = "D:/wamp/www/test/gmail-imap/upload/";
// Open a directory, and read its contents
if (is_dir($dir)){
if ($dh = opendir($dir)){
if ($handle = opendir('.')) {
while (false !== ($entry = readdir($handle))) {
if ($entry != "." && $entry != "..") {
echo "$entry\n";
}
}
closedir($dh);
}
}
}