简体   繁体   English

PHP Scandir云文件夹

[英]PHP Scandir Cloud Folder

I Would like to know how i could do a simple scandir of a folder in a cloud storage, or if it's even possible. 我想知道如何在云存储中对文件夹进行简单的scandir ,或者是否有可能。

<?php
$dir = "C:/wamp64/www/test";
$a = scandir($dir);
$files = array_diff($a, array('.', '..'));
file_put_contents("C:/wamp64/www/test.txt", "");
foreach ($files as $key) {
    file_put_contents("C:/wamp64/www/test.txt","$key \r\n", FILE_APPEND);
}
?>

I have this code currently working fine, but my cloud path is L:\\2017 and putting those values will just say No such file or directory 我的代码当前工作正常,但是我的云路径为L:\\2017 ,并输入这些值只会说没有这样的文件或目录

Any help appreciated, and sorry for the inconvenience! 不胜感激,不便之处,敬请原谅!

You should do something like this: 您应该执行以下操作:

<?php
$path = '\\2017\somepath\';

$user = "username";
$pass = "password";
$drive_letter = "L";

system("net use ".$drive_letter.": \"".$path."\" ".$pass." /user:".$user." /persistent:no>nul 2>&1");
$location = $drive_letter.":/somepath/your_directory";

if ($handle = opendir($location)) {
    while (false !== ($entry = readdir($handle))) {
    echo "$entry";
    } 
    closedir($handle);
}
?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM