UploadCare does not upload image in dialog

I expect the UploadCare dialog to open after clicking the MyButton button that displays the Twitter logo, but that is not the case. Why not?

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

You need to pass the object fileas an argument to the method openDialog. You can get the file object by calling the 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;
});
+3
source

Source: https://habr.com/ru/post/1568695/


All Articles