https://github.com/qiniu/php-sdk/blob/master/examples/up.php
這裡是七牛上傳檔案的原始碼,截取部分如下
require_once DIR . '/../autoload.php';
use Qiniu\Auth;
use Qiniu\Storage\UploadManager;
$accessKey = 'Access_Key';
$secretKey = 'Secret_Key';
$auth = new Auth($accessKey, $secretKey);
$bucket = 'Bucket_Name';
$token = $auth->uploadToken($bucket);
$uploadMgr = new UploadManager();
// 上傳檔案到七牛
$filePath = './php-logo.png';
$key = 'php-logo.png';
list($ret, $err) = $uploadMgr->putFile($token, $key, $filePath);
echo "\n====> putFile result: \n";
if ($err !== null) {
var_dump($err);
} else {
var_dump($ret);
}
?>
提幾個問題
1.代碼應該縮排
2.用詞不當
$key = 'php-logo.png'; 這一行我感覺,不是密碼的意識,密碼已經在
$accessKey = 'Access_Key';
$secretKey = 'Secret_Key';
應當是檔案名稱的意識,應當用 $fname
3.作者為何不寫英語注釋?
請讓我來修改一下
require_once __DIR__ . '/../autoload.php';use Qiniu\Auth;use Qiniu\Storage\UploadManager;$accessKey = 'Access_Key';$secretKey = 'Secret_Key';$auth = new Auth($accessKey, $secretKey);$bucket = 'Bucket_Name';$token = $auth->uploadToken($bucket);$uploadMgr = new UploadManager();// upload file into qiniu$filePath = './php-logo.png';$fname = 'php-logo.png';list($ret, $err) = $uploadMgr->putFile($token, $fname, $filePath);echo "\n====> putFile result: \n";if ($err !== null) { var_dump($err);} else { var_dump($ret);}
?>
多高大上,白富美哈!!
這個問題已被關閉,原因:非技術提問的討論型問題
回複內容:
https://github.com/qiniu/php-sdk/blob/master/examples/up.php
這裡是七牛上傳檔案的原始碼,截取部分如下
require_once DIR . '/../autoload.php';
use Qiniu\Auth;
use Qiniu\Storage\UploadManager;
$accessKey = 'Access_Key';
$secretKey = 'Secret_Key';
$auth = new Auth($accessKey, $secretKey);
$bucket = 'Bucket_Name';
$token = $auth->uploadToken($bucket);
$uploadMgr = new UploadManager();
// 上傳檔案到七牛
$filePath = './php-logo.png';
$key = 'php-logo.png';
list($ret, $err) = $uploadMgr->putFile($token, $key, $filePath);
echo "\n====> putFile result: \n";
if ($err !== null) {
var_dump($err);
} else {
var_dump($ret);
}
?>
提幾個問題
1.代碼應該縮排
2.用詞不當
$key = 'php-logo.png'; 這一行我感覺,不是密碼的意識,密碼已經在
$accessKey = 'Access_Key';
$secretKey = 'Secret_Key';
應當是檔案名稱的意識,應當用 $fname
3.作者為何不寫英語注釋?
請讓我來修改一下
require_once __DIR__ . '/../autoload.php';use Qiniu\Auth;use Qiniu\Storage\UploadManager;$accessKey = 'Access_Key';$secretKey = 'Secret_Key';$auth = new Auth($accessKey, $secretKey);$bucket = 'Bucket_Name';$token = $auth->uploadToken($bucket);$uploadMgr = new UploadManager();// upload file into qiniu$filePath = './php-logo.png';$fname = 'php-logo.png';list($ret, $err) = $uploadMgr->putFile($token, $fname, $filePath);echo "\n====> putFile result: \n";if ($err !== null) { var_dump($err);} else { var_dump($ret);}
?>
多高大上,白富美哈!!
題主顯然工作量不飽和呀。
關鍵是你要問的問題是什麼呢?segmentfault是個問答平台,你這個意見你應該去七牛的github項目上提issue或者上v2ex上發文章吧?
七牛的趕緊把樓主請去當CTO,不然?