#native_company# #native_desc#
#native_cta#

smb4php: a smb stream wrapper

By Victor M Varela
on October 15, 2007

smb4php is a ‘smbclient’ based stream wrapper for PHP to access files and folders shared by an SMB server in a transparent way. You will be able to use fopen, fclose, fwrite, fgets, opendir, readdir, unlink, etc. using an URL “smb://user:pass@server/share/path”;.

Example:

include "smb.php";

$dir = "smb://server/disk";
if(is_dir($dir)) {
   $dh = opendir($dir);
   while(($file=readdir($dh)) !== false) {
       echo "filename: $file - filetype: ".filetype($dir.'/'.$file)."n";
   }
   closedir($dh);
}
else {
   echo $dir." n'est pas un r??pertoire
n"; }