Reputation: 1519
I am working on php code as shown below in which I want to read a network drives as shown below :
$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)
.
Upvotes: 3
Views: 1827
Reputation: 2811
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:
I hope this helps!
Upvotes: 1