35 lines
1.1 KiB
PHP
35 lines
1.1 KiB
PHP
<?php
|
|
namespace addon\aliapp\model;
|
|
use app\model\BaseModel;
|
|
class UploadFile extends BaseModel
|
|
{
|
|
public function putFile($param)
|
|
{
|
|
try {
|
|
$file_path = $param["file_path"];
|
|
$key = $param["key"];
|
|
$site_id = 1;
|
|
if (isset($param['site_id'])) {
|
|
$site_id = $param['site_id'];
|
|
}
|
|
$miniapp = new MinCode($site_id);
|
|
$image = $miniapp->imageUpload(md5($key), $file_path, true);
|
|
$res = $image['alipay_offline_material_image_upload_response'];
|
|
if ($res['code'] == 10000) {
|
|
$data = array(
|
|
"type" => 'alipay',
|
|
"path" => $res['image_url'],
|
|
"url" => $res['image_url'],
|
|
"domain" => '',
|
|
"image_id" => $res['image_id'],
|
|
"bucket" => $res['image_id']
|
|
);
|
|
return $this->success($data);
|
|
} else {
|
|
return $this->error($res);
|
|
}
|
|
} catch (\Exception $e) {
|
|
return $this->error( $e->getMessage());
|
|
}
|
|
}
|
|
} |