1. To integrate Alibaba Cloud OSS PHP-SDK 2.0.4 into OneThink (ThinkPHP3.2.3) to implement web direct upload, server-side signed direct upload, and upload callback, the prerequisite is to first follow the implementation at: https://www.shuijingwanwq.com/2016/01/13/909/ to configure the CORS for the Bucekt (storage4-hmwis-com), as shown in Figure 0;

2. Review the help documentation on Web Direct Upload Practices — Server-Signed Direct Upload and Upload Callback. Download the code examples: application server signature return code: oss-h5-upload-js-php-callback.tar.gz, and callback application server version: callback-php-demo.zip, as shown in Figures 1 and 2.


3. Copy the function gmt_iso8601 from E:\wwwroot\oss-h5-upload-js-php-callback\php\get.php 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 and create a new upload form method, as shown in Figure 4.
/* File upload form, based on OSS, web direct upload */
public function ossUpload(){
$this->display();
}

5. Open E:\wwwroot\oss-h5-upload-js-php\index.html, copy all content to E:\wwwroot\ke.hmwis.com\Application\Home\View\default\File\ossUpload.html, and adjust the corresponding file paths within it, as shown in Figure 5.

6. Open http://ke.ygt.cm/File/ossUpload.html and view the web page source code, as shown in Figure 6.

7. Copy the corresponding files from E:\wwwroot\oss-h5-upload-js-php-callback to the 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 and import the OSS client class and exception class, 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 all code except function gmt_iso8601 into the public function ossGet() in E:\wwwroot\ke.hmwis.com\Application\Home\Controller\FileController.class.php, and instantiate the OSS 2.0.4 client class, as shown in Figure 9.

10. Configure the virtual host for zhidao.ygt.cm:
* Note: If you want to use the HTTP_AUTHORIZATION header, you must first set up a rewrite in Apache or Nginx. Taking Apache as an example, modify
* the configuration file /etc/httpd/conf/httpd.conf (based on 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 upload test is successful, as shown in Figures 13 and 14.


14. The callback test is successful. View zhidao.ygt.cm/data/1.txt, as shown in Figure 15.
“filename=user-dir%2F10.png&size=218185&mimeType=image%2Fpng&height=453&width=674”

