コード例 #1
0
ファイル: floderup.php プロジェクト: greatqn/folder2oss
    foreach ($filesarr as $key => $file) {
        _log('m file :' . $file);
        //上传动作:
        $object = str_replace($host, "", $file);
        $file_path = $file;
        $response = $oss_sdk_service->upload_file_by_file($bucket, $object, $file_path);
        _format($response);
        unset($filesarr[$key]);
        file_put_contents(M_FILE, serialize($filesarr));
    }
    @unlink(M_FILE);
    exit;
}
$file_list = array();
foreach ($floder as $f) {
    record_md5($f);
}
if (file_exists(M_LOG)) {
    $log = unserialize(file_get_contents(M_LOG));
} else {
    $log = array();
}
file_put_contents(M_LOG, serialize($file_list));
if (count($file_list) > 0) {
    foreach ($file_list as $file => $md5) {
        if (!isset($log[$file])) {
            _log('add:' . $file);
            $filesarr[] = $file;
        } else {
            if ($log[$file] != $md5) {
                //print '修改:'.$file."\r\n";
コード例 #2
0
ファイル: tutorial.php プロジェクト: greatqn/folder2oss
function record_md5($dir)
{
    global $file_list;
    if (is_dir($dir)) {
        $file = scandir($dir);
        foreach ($file as $f) {
            if ($f != '.' && $f != '..') {
                $path = $dir . '/' . $f;
                if (is_dir($path)) {
                    record_md5($path);
                } else {
                    $file_list[$path] = md5_file($path);
                }
            }
        }
    }
}