<?php

set_time_limit(0);

// 引入自动加载类
// 确保路径是否正确

require_once 'autoload.php';

// 确定参数 需要申请

$accessKeyId = "*****";
$accessKeySecret = "*****";
$endpoint = "*****";
$bucket = "*****";

// 实例化

$ossClient = new \OSS\OssClient($accessKeyId, $accessKeySecret, $endpoint);

// scandir()函数返回指定目录中的文件和目录的数组。

$filesnames = scandir('./img');

// 遍历

foreach ($filesnames as $name) {

if('.'==$name || '..'==$name || 'Thumbs.db'==$name ){
continue;
}

$filePath = 'upload/photo/'.$name; // 上传至服务器的名字
$url = './img/'.$name; // 本地文件的名字

echo $url."\n";
$ossClient->uploadFile($bucket, $filePath, $url);

}

 

?>

posted on 2016-09-27 16:08  啥也不会的程序猿  阅读(3054)  评论(0编辑  收藏  举报