如何在Cloudinary中获取上载图像的URL,以便在使用PHP上传文件时可以将其保存在数据库中?
答案 0 :(得分:0)
如果您使用Cloudinary PHP SDK to perform the upload,则对SDK的Upload方法的调用响应将包含新上传的图像的元数据
此处的文档中有一个示例: https://cloudinary.com/documentation/php_image_and_video_upload#upload_response
Array
(
[public_id] => c87hg9xfxrd4itiim3t0
[version] => 1571218607
[signature] => f8645b000be7d717599affc89a068157e4748276
[width] => 864
[height] => 576
[format] => jpg
[resource_type] => image
[created_at] => 2017-06-23T13:59:18Z
[bytes] => 120253
[type] => upload
[url] => http://res.cloudinary.com/demo/image/upload/v1571218607/c87hg9xfxrd4itiim3t0.jpg
[secure_url] => https://res.cloudinary.com/demo/image/upload/v1571218607/c87hg9xfxrd4itiim3t0.jpg
)
url
和secure_url
将返回原始图像,但是为了访问该图像的派生版本,您还应该存储public_id
,resource_type
,{{1 }} type
,format
,因此您可以正确跟踪资产,并在应用程序中使用图像时将必要的值传递给version
或cl_image_tag()
。