关于php:使用Cloudinary上传文件后获取mime类型

Getting mime type after file upload with Cloudinary

考虑使用Cloudinary PHP API上传文件:

1
\\Cloudinary\\Uploader::upload('http://www.example.com/image.jpg');

如重复说明中所述,基本响应不包括上载文件的mime-type

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Array
(
  [public_id] => c87hg9xfxrd4itiim3t0
  [version] => 1371995958
  [signature] => f8645b000be7d717599affc89a068157e4748276
  [width] => 864
  [height] => 576
  [format] => jpg
  [resource_type] => image
  [created_at] => 2013-06-23T13:59:18Z
  [bytes] => 120253
  [type] => upload
  [url] => http://res.cloudinary.com/demo/image/upload/v1371995958/c87hg9xfxrd4itiim3t0.jpg
  [secure_url] => https://res.cloudinary.com/demo/image/upload/v1371995958/c87hg9xfxrd4itiim3t0.jpg
)

我是否需要在设置中配置某些内容才能将其添加到响应中?


检查别人上传的内容的mime类型永远都不安全。
可以很容易地伪造。

如果您只想上传图像(例如在示例中),最安全的方法是使用GD或ImageMagick

重新处理图像