UploadCare不会在对话框中加载图像

时间:2014-12-23 02:58:59

标签: javascript uploadcare

我希望在单击MyButton后打开UploadCare对话框,显示Twitter徽标,但事实并非如此。为什么不呢?

$('#MyButton').on('click', function() {
    uploadcare.openDialog('https://g.twimg.com/About_logoUsage.png');
    return false;
});

1 个答案:

答案 0 :(得分:3)

您需要将file对象作为参数传递给openDialog方法。您可以通过调用uploadcare.fileFrom方法获取文件对象:

// Pre-load an image from arbitrary URL,
// and open Uploadcare file upload dialog
$('#MyButton').on('click', function() {
    var file = uploadcare.fileFrom('url', 'https://g.twimg.com/About_logoUsage.png');
    uploadcare.openDialog(file);
    return false;
});