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 编写vba代码实现数据录入工作
  • ¥15 做过TCL海信电视小米电视相关影视会员软件私我
  • ¥15 Mapreduce是正常的,在运行其他jar包时并没有任何问题,只是在做LogCount.jar 时出的问题。如图所示
  • ¥15 ImportError: DLL load failed while importing _iterative: 找不到指定的模块。
  • ¥15 如何通过交互分析得出某高危患者对放疗获益更多
  • ¥15 相关性分析中,p<0.05, r=0.29,怎么评价相关性呢
  • ¥15 docker部署Mongodb后输入命令报错?
  • ¥15 将下列流程图转变成python程序代码
  • ¥15 我需要全国每个城市的最新小区名字等数据。
  • ¥15 开发一个小区生态的小程序