4

I expect the UploadCare dialog to open after clicking MyButton, showing the Twitter logo, but it doesn't. Why not?

$('#MyButton').on('click', function() {
    uploadcare.openDialog('https://g.twimg.com/About_logoUsage.png');
    return false;
});
bart
  • 14,958
  • 21
  • 75
  • 105

1 Answers1

3

You need to pass a file object as an argument to openDialog method. You can obtain the file object by calling uploadcare.fileFrom method:

// 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;
});
David Avsajanishvili
  • 7,678
  • 2
  • 22
  • 24