Integrate the PHP-SDK2.0.4 of Alibaba Cloud OSS in OneThink (ThinkPHP3.2.3) to realize direct transfer on the web side, direct transfer of the server signature and set the implementation process of uploading callbacks
1. In OneThink (ThinkPHP3.2.3), integrate the PHP-SDK2.0.4 of Alibaba Cloud OSS to realize direct transfer on the web, and the server-side signature is directly transmitted and uploaded callbacks, provided that you first refer to:https://www.shuijingwanwq.com/en/2016/01/13/10177/Implementation, set the CORS of Bucekt (Storage4-HMWIS-COM), as shown in Figure 0;
2. Check the practice of direct transmission on the web side of the help document – the server-side signature is directly uploaded and the upload callback is set, download the code example, and the application server returns the signature code: oss-h5-uplo ad-js-php-callback.tar.gz, callback application server version: callback-php-demo.zip, as shown in Figure 1, 2
3. Copy: E:\wwwroot\oss-h5-upload-js-php-callback\php\get.php GMT_ISO8601 to E:\wwwroot\ke.hmwis.com\Application\Common\Common\Function.php, as shown in Figure 3
4. Open: E:\wwwroot\ke.hmwis.com\application\home\controller\filecontroller.class.php, create a new upload form method, as shown in Figure 4
/* File upload form, based on OSS, web direct transmission */
public function ossupload(){
$this->display();
}
5. Open: E:\wwwroot\oss-h5-upload-js-php\index.html, copy all the content to: e:\wwwroot\ke.hmw Is.com\Application\Home\View\Default\File\Ossupload.html, and adjust the corresponding file path, as shown in Figure 5
6. Open:http://ke.ygt.cm/File/ossUpload.html, view the source code of the web page, as shown in Figure 6
7. Copy the corresponding files under e:\wwwroot\oss-h5-upload-js-php-callback to: e :\wwwroot\static.hmwis.com\ke\public\static\oss directory, as shown in Figure 7
8. Open: E:\wwwroot\oss-h5-upload-js-php-callback\php\get.php, import the client class and exception class of oss, as shown in Figure 8
use oss\ossclient;
use oss\core\OSSException;
9. Open: E:\wwwroot\oss-h5-upload-js-php-callback\php\get.php, copy and remove function All codes other than GMT_ISO8601 go to: e:\wwwroot\ke.hmwis.com\application\home\controller\filecontroller.class.php function ossget(), and instantiate the client class of OSS2.0.4, as shown in Figure 9
10. Configure the virtual host of zhidao.ygt.cm:
* Note: If you want to use the http_authorization header, you need to set rewrite in apache or nginx first, take apache as an example, modify
* Configuration file /etc/httpd/conf/httpd.conf (subject to your apache installation path), as shown in Figure 10
add a line:
rewriterule .* -[env=HTTP_AUTHORIZATION:%{HTTP:Authorization},last]
11. Edit: E:\wwwroot\static.hmwis.com\ke\public\static\oss\upload.js, as shown in Figure 11
phpURL =http://ke.ygt.cm/File/ossGet.html
12. Edit: E:\wwwroot\oss-h5-upload-js-php-callback\callback.php, as shown in Figure 12
file_put_contents(./data/1.txt, json_encode($body));
13. The test upload is successful, as shown in Figure 13 and 14
14. The test callback is successful, check zhidao.ygt.cm/data/1.txt, as shown in Figure 15
“filename=user-dir%2f10.png&size=218185&m IMEType=image%2fpng&height=453&width=674”















