PHP code example of itboye / component_oss

1. Go to this page and download the library: Download itboye/component_oss library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

itboye / component_oss example snippets


$cfg = new AliyunOssConfig();
...设置 key 密钥,endpoint,bucket名称

$uploader = new AliyunOss(new DemoConfig());

//如果指定了,$result 返回是同步请求该地址的结果
$callbackUrl = "";
$params = [];// 携带参数

$localpath = dirname(__DIR__)."/qiniu/demo.png";
$saveName = "/path/1.jpg";
$result = $uploader->putFile($saveName, $localpath, $cb, $params);
var_dump($result);