I am working on a php code as shown below in which I want to access network drive folder (music) using credentials in php. The credentials is being set because I want to give the full access only to a particular user.
$src_dir = '\\\\\\INVEST-OP-001\\test\\music';
// Line#A
The full permission/access of music folder is given to the following credentials:
username : 'mickeymouse'
password : 'helloworld'
Problem Statement:
I am wondering what changes I should make in the php code at Line#A so that I can access the music folder using credentials in php.
This works for me:
<?php
$user = 'mickeymouse';
$password = 'helloworld';
exec('net use "\\\INVEST-OP-001\test\music" /user:"'.$user.'" "'.$password.'" /persistent:no');
$files = scandir('\\\INVEST-OP-001\test\music');
echo '<pre>';
print_r($files);
exec('net use "\\\INVEST-OP-001\test\music" /delete /yes');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.