Epay.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace app\admin\controller;
  3. use app\common\controller\Backend;
  4. use think\Config;
  5. class Epay extends Backend
  6. {
  7. protected $noNeedRight = ['upload'];
  8. /**
  9. * 上传本地证书
  10. * @return void
  11. */
  12. public function upload()
  13. {
  14. Config::set('default_return_type', 'json');
  15. $certname = $this->request->post('certname', '');
  16. $certPathArr = [
  17. 'cert_client' => '/addons/epay/certs/apiclient_cert.pem', //微信支付api
  18. 'cert_key' => '/addons/epay/certs/apiclient_key.pem', //微信支付api
  19. 'app_cert_public_key' => '/addons/epay/certs/appCertPublicKey.crt',//应用公钥证书路径
  20. 'alipay_root_cert' => '/addons/epay/certs/alipayRootCert.crt', //支付宝根证书路径
  21. 'ali_public_key' => '/addons/epay/certs/alipayCertPublicKey.crt', //支付宝公钥证书路径
  22. ];
  23. if (!isset($certPathArr[$certname])) {
  24. $this->error("证书错误");
  25. }
  26. $url = $certPathArr[$certname];
  27. $file = $this->request->file('file');
  28. if (!$file) {
  29. $this->error("未上传文件");
  30. }
  31. $file->move(dirname(ROOT_PATH . $url), basename(ROOT_PATH . $url), true);
  32. $this->success(__('上传成功'), '', ['url' => $url]);
  33. }
  34. }