简体   繁体   English

使用Cloudinary上传文件后获取哑剧类型

[英]Getting mime type after file upload with Cloudinary

Consider uploading a file using Cloudinary PHP API: 考虑使用Cloudinary PHP API上传文件:

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

As stated in the doumentation , a basic response does not include the mime-type of the uploaded file: doumentation中所述 ,基本响应不包括上传文件的mime-type

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
)

Do I have to configure something in the settings to have it added to the response? 我是否需要在设置中配置某些内容才能将其添加到响应中?

Its never safe to check the mime type of something uploaded by someone else. 检查别人上传的MIME类型永远都不安全。 It can be faked easily. 它很容易被伪造。

If you only want to upload image (like in the exemple) the safest method is to re-process the image using GD or ImageMagick 如果您只想上传图片(例如在示例中),最安全的方法是使用GD或ImageMagick重新处理图片

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM