我的应用程序中有以下代码将图像上传到imagekit。我正在使用这个官方包
function uploadImage ($base64Img, $fileName, $folder, $h, $w, $aratio){
$imageKit = new ImageKit(
"public_key,
"private_key",
"urlEndpoint"
);
$config = [
'file' => $base64Img, //imageconverted to Base64
'fileName' => $fileName,
'folder' => $folder, //foldername
"transformation" => array(
array(
"height" => "300",
"width" => "400",
)
)
];
// if (isset($h) && isset($w)) {
// $config['transform'] = [
// [
// "height" => $h,
// "width" => $w
// ]
// ];
// }
// if (isset($aratio)) {
// $config['transform'] = [
// [
// "ar" => '1:1',
// ]
// ];
// }
// Upload Image - base64
$uploadFile = $imageKit->upload($config);
return($uploadFile->success->url);
}
根据官方文档,返回 url 应该是这样的:
https://ik.imagekit.io/your_imagekit_id/endpoint/tr:h-300,w-400/my_file_name.jpg
;
但我得到的只是没有转换的 url:
https://ik.imagekit.io/your_imagekit_id/endpoint/file_name.jpg
谁能帮我解决这个问题?