duancui19840401 2019-05-27 16:24
浏览 97

如何在php中访问网络驱动器上的目录/文件夹?

I have a mapped network drive called M local to my machine which I am trying to access through php. The folder which I am trying to access from M drive is in_folder present inside music folder. This is what I have tried:

<?php
$src_dir = '\\\\younetworkdrive\\music\\in_folder';    // in_folder is the the folder present on a network drive M inside music folder 

$user = "mickeymouse";
$pass = "waltdisney";
$drive_letter = "M";

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

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

$mp4_files = preg_grep('~\.(mp4)$~', scandir($src_dir));

$xml_files = preg_grep('~\.(xml)$~', scandir($src_dir));

?>

Problem Statement:

I tried with the php code above but it doesn't seem to work. Unfortunately, I don't have logs setup so I am unable to track the error. I am wondering if there is any mistake in the php code above.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 centos7.9 IPv6端口telnet和端口监控问题
    • ¥120 计算机网络的新校区组网设计
    • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
    • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
    • ¥20 海浪数据 南海地区海况数据,波浪数据
    • ¥20 软件测试决策法疑问求解答
    • ¥15 win11 23H2删除推荐的项目,支持注册表等
    • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
    • ¥15 qt6.6.3 基于百度云的语音识别 不会改
    • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单