如何在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.