我为 cloudinary 创建了一个有效的客户端上传脚本。上传的重要部分:
<?php
$cloudName = "...";
$apiKey = "...";
$time = time();
$apiSecret = "...";
$fileName = "...";
?>
<form action="https://api.cloudinary.com/v1_1/<?php echo $cloudName;?>/image/upload" method="post" enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="file" id="file"><br>
<input type="hidden" name="signature" value="<?php echo sha1('public_id='.$fileName.'×tamp='.$time.$apiSecret);?>" />
<input type="hidden" name="api_key" value="<?php echo $apiKey; ?>"/>
<input type="hidden" name="timestamp" value="<?php echo $time; ?>" />
<input type="hidden" name="public_id" value="<?php echo $fileName; ?>" />
<input type="submit" name="submit" value="Submit">
</form>
现在我想为上传添加一个转换,所以上传在存储之前进行转换(以节省存储空间)。
我尝试添加以下代码(其中 resize 是我在我的 cloudinary 帐户中创建的转换)。
<input type="hidden" name="transformation" value="resize" />
但是带有转换字段的请求会导致401 未经授权的错误。我想我必须对签名做一些事情,但是什么?