Jump to content

Finding name of last created file on smb server


tonyio

Recommended Posts

I need to reach Win server, scan shared folder and find out what is last created file name on this folder, and than copy this file to local folder. BUT main problem is smb, never used it before, and this is what i came up  with, but no luck.

require_once('smbclient.php');
$latest = null;

    $smbc = new smbclient ('//10.1.1.10/Share/Address Verification/', 'domain\\username', 'password');
     if ($handle = opendir($smbc)) {
    $latest = null;
    while (($cur = readdir($handle) !== false)) {
        if ($latest == null || filectime($cur) > filectime($latest)) {
            $latest = $cur;
        }
    }
    closedir($handle);
}
return $latest;

please help, returns Warning: opendir() expects parameter 1 to be string

i never worked with samba, and i going mad, coz this is second day for this simple task...and i cannot solve it

I am not familiar with this php class at all, but have experience with samba servers (by the way, actually this is not a samba server). Have you tried to establish a connection using smbclient from your Unix machine?

I am not familiar with this php class at all, but have experience with samba servers (by the way, actually this is not a samba server). Have you tried to establish a connection using smbclient from your Unix machine?

smbclient connection works perfectly, i use it to get  files with known names, but at this case i can't know the name, i need to find name of most recent file that exist in the directory.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.