多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
文件上传推荐使用前端直传OSS,不推荐上传到服务器后转存。 项目使用composer 安装阿里云OSS上传组件 ~~~ composer require aliyuncs/oss-sdk-php ~~~ 上传文件代码示例: ~~~ $ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint); $bucket = "tovercq"; $resut = $ossClient->uploadFile(bucket名称, 'object名称', '本地文件路径'); ~~~ #### $accessKeyId 从OSS获得的AccessKeyId #### $accessKeySecret 从OSS获得的AccessKeySecret #### $endpoint 您选定的OSS数据中心访问域名,例如:oss-cn-hangzhou.aliyuncs.com 请根据自己业务处理返回数据。 阿里云OSS上传返回参数: ~~~ array(15) { ["server"] => string(9) "AliyunOSS" ["date"] => string(29) "Thu, 10 Jan 2019 06:23:14 GMT" ["content-length"] => string(1) "0" ["connection"] => string(10) "keep-alive" ["x-oss-request-id"] => string(24) "5C36E4D22BFA718B4D8C208C" ["etag"] => string(34) ""F0ABB5590B390FE7C8E97EF301351696"" ["x-oss-hash-crc64ecma"] => string(19) "9372706288141247284" ["content-md5"] => string(24) "8Ku1WQs5D+fI6X7zATUWlg==" ["x-oss-server-time"] => string(2) "38" ["info"] => array(27) { ["url"] => string(57) "http://tovercq.oss-cn-beijing.aliyuncs.com/hy/osstest.txt" ["content_type"] => NULL ["http_code"] => int(200) ["header_size"] => int(334) ["request_size"] => int(390) ["filetime"] => int(-1) ["ssl_verify_result"] => int(0) ["redirect_count"] => int(0) ["total_time"] => float(0.141) ["namelookup_time"] => float(1.0E-6) ["connect_time"] => float(0.047) ["pretransfer_time"] => float(0.047) ["size_upload"] => float(23) ["size_download"] => float(0) ["speed_download"] => float(0) ["speed_upload"] => float(23) ["download_content_length"] => float(0) ["upload_content_length"] => float(23) ["starttransfer_time"] => float(0.094) ["redirect_time"] => float(0) ["redirect_url"] => string(0) "" ["primary_ip"] => string(13) "59.110.190.11" ["certinfo"] => array(0) { } ["primary_port"] => int(80) ["local_ip"] => string(13) "192.168.0.197" ["local_port"] => int(58009) ["method"] => string(3) "PUT" } ["oss-request-url"] => string(57) "http://tovercq.oss-cn-beijing.aliyuncs.com/hy/osstest.txt" ["oss-redirects"] => int(0) ["oss-stringtosign"] => string(69) "PUT text/plain Thu, 10 Jan 2019 06:23:39 GMT /tovercq/hy/osstest.txt" ["oss-requestheaders"] => array(5) { ["Accept-Encoding"] => string(0) "" ["Content-Type"] => string(10) "text/plain" ["Date"] => string(29) "Thu, 10 Jan 2019 06:23:39 GMT" ["Host"] => string(35) "tovercq.oss-cn-beijing.aliyuncs.com" ["Authorization"] => string(49) "OSS LTAIwK1sEYUFSJMg:eYDED1Ivx8igB0N6iFgUo4V7M8k=" } ["body"] => string(0) "" } ~~~ 具体OSS参数请登录[https://docs.qq.com/doc/DY1FkUHFQRlZDUVNE](https://docs.qq.com/doc/DY1FkUHFQRlZDUVNE)或联系相关人员 阿里云OSS传送门:https://help.aliyun.com/product/31815.html?spm=a2c4g.11186623.6.540.793010d5hxXNgg