dqiaw48488 2019-05-27 18:33 采纳率: 0%
浏览 27
已采纳

如何从php中的网络驱动器读取文件?

I am working on php code as shown below in which I want to read a network drives as shown below :

enter image description here

$src_dir = is_dir("\\\\ADMPC02-02\\music\\incoming_folder\\");    // Line#A

var_dump($src_dir);  // bool(false)

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

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

print_r($mp4_files);  // it doesn't print anything

print_r($xml_files);  // it doesnt print anything

Problem Statement:

I am wondering what changes I need to make at Line#A so that I am successfully able network directory. On doing var_dump($src_dir); it prints bool(false).

  • 写回答

1条回答 默认 最新

  • douda5227 2019-05-27 18:46
    关注

    This works for me:

    <?php
    
    $src_dir = '\\\ADMPC02-02\test';
    $is_dir = is_dir($src_dir); // returns true
    $mp4_files = preg_grep('~\.(mp4)$~', scandir($src_dir));
    $xml_files = preg_grep('~\.(xml)$~', scandir($src_dir));
    
    echo '<pre>';
    print_r($mp4_files); // lists all the mp4 files in my 'test' folder
    print_r($xml_files); // lists all the xml files in my 'test' folder
    

    You should also make sure that:

    1. Network discovery is On
    2. Files and printers sharing is On
    3. Your music folder is publicly shared will all required permissions for the current Windows user running PHP

    I hope this helps!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置