network drive
Moderator: General Moderators
network drive
I have a mapped network drive (S) and im wanting to read in data from a file on this drive how can I do this with php? can i change directory to this mapped drive??? please help
Alright I am changing this answer because a post below this one reminded me of something whatever user the web server is running as will not have a drive mapped as s: currently so you will need to use the UNC mapping (ie:/somecomputer/somefolder/) for the drive and then that user must have access to that drive.
- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK
Code: Select all
$file = file_get_contents('S:/dir/file.txt');- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK
Any IO function that PHP supports is hooked into all mapped or network drives that have open access to the share. If you need to support login via a share then PHP can not access the network drive, you will have to access it using COM via PHP!
For mapped or network drives all you do is supply the Network Indentification followd by the SHARE name and then the path an file name or directory you want to read!
Network Indentification is the computer name that contains the mapped drive or share...
Share is the common name of the mapped drive or directory being shared on some dive....
So, file get contents
echo file_get_contents ( '//Network Indentification/Share/file.txt' );
Say the computer name is my_network, the Share is my_folder, my_folder points to drive F:, now say I want access all the files that are in my_folder, but in sub-folder called images, so I would...
a mapped drive is just like using symbolic links on Unix or Linux, where the mapping can be local or across the world!
printf
For mapped or network drives all you do is supply the Network Indentification followd by the SHARE name and then the path an file name or directory you want to read!
Network Indentification is the computer name that contains the mapped drive or share...
Share is the common name of the mapped drive or directory being shared on some dive....
So, file get contents
echo file_get_contents ( '//Network Indentification/Share/file.txt' );
Say the computer name is my_network, the Share is my_folder, my_folder points to drive F:, now say I want access all the files that are in my_folder, but in sub-folder called images, so I would...
Code: Select all
<?php
$files = glob ( '//my_network/my_folder/images/*' );
print_r ( $files );
?>printf