使用 Cloudinary API 使用 jQuery 直接上传图片

Direct image upload using Cloudinary API using jQuery

我正在尝试使用 jQuery 使用 Cloudinary 图像上传 API 上传图像。我对此一无所知。我正在使用以下代码。 我不知道我们在签名参数中使用什么值。

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
        <title>Insert title here</title>
        <script src="http://code.jquery.com/jquery-1.9.0.js"></script>
        <script src="js/jquery.ui.widget.js"></script>
        <script src="js/jquery.iframe-transport.js"></script>
        <script src="js/jquery.fileupload.js"></script>
        <script src="js/jquery.cloudinary.js"></script> 
    </head>
    <body>
        <script type="text/javascript">
            $.cloudinary.config({"api_key":"api_key","cloud_name":"cloud_name"});
        </script> 
        <input name="file" type="file" id="uploadinput"
            class="cloudinary-fileupload" data-cloudinary-field="image_upload" 
            data-form-data="" ></input>
        <script>
            var data = { "timestamp":  '', 
              "callback": "http//localhost/cloudinar/index.php?message='file     has been uploaded'",
              "signature": "", 
              "api_key": "api_key" };    
              $('#uploadinput').attr('data-form-data', JSON.stringify(data));
        </script>
    </body>
</html>

Cloudinary服务端SDK支持自动生成输入框,输入框自动包含相应的签名。 如需更多信息(例如,使用 PHP): http://cloudinary.com/documentation/php_image_upload#direct_uploading_from_the_browser

与支持人员交谈后,我被引导至 this post, which shows how to upload files directly to Cloudinary, as simple as possible, with "unsigned" 方法:

$('.upload_field').unsigned_cloudinary_upload("zcudy0uz", 
    { cloud_name:'demo', tags:'browser_uploads' }, 
    { multiple:true }
)
.on('cloudinarydone', function(e, data){
    var opts = { 
        format  : 'jpg',
        width   : 150,
        height  : 100,
        crop    : 'thumb',
        gravity : 'face',
        effect  : 'saturation:50'
    };

    $('.thumbnails').append( $.cloudinary.image(data.result.public_id, opts) )
})
.on('cloudinaryprogress', function(e, data){ 
    var W = Math.round((data.loaded * 100.0) / data.total) // %
    $('.progress_bar').css('width', W + '%'); 
});

一个名叫 "Maor Gariv" 的人也给了我一个 demo page,他回复了我的支持邮件。