PHP中利用CURL上传文件

in 普通BLOG
0 评论 阅读量:535

项目背景

汇付创建实名认证的对象需要上传对应资质文件

$value; // 上传的文件路径  /uploads/attach/2023/11/20231123/v2.1.3-20231030.zip
$local_path = realpath(public_path() . $value);
$filename_temp = explode('/', $value);

$data[$field] = new \CURLFile($local_path, getmimefile($local_path), end($filename_temp) ?? $value);
$file_upload = true;


function getmimefile($file)
{
    $finfo = finfo_open(FILEINFO_MIME_TYPE);
    $ftype = finfo_file($finfo, $file);
    finfo_close($finfo);
    return $ftype;
}

参考资料

汇付支付-创建更新/企业用户对象

php通过curl上传文件

通过CURL上传-如何更改目标文件名?

Comments are closed.