1

I am using Uploadcare on my site and I am loving it.

I have one problem though I am using a bootstrap modal which I load the data through AJAX. I want Uploadcare widget to recognise that the file already exists and show the picture (not ask to upload new). Is there a way to force the widget to refresh and read the value="". If I set the value before it works as intended.

My code is below: data[4] returns the URL of the Uploadcare image

<input type="hidden"
       id="editurl"
       name="url"
       role="uploadcare-uploader"
       data-crop=""
       data-images-only="true">

$.ajax({
        type: "POST",
        dataType: "json",
        url: "worker.php",
        data: "action=details&id="+ id +"",
        error: function() {
            show_notification("danger", "warning-sign", "Ajax query failed!");
        },
        success: function(data) {
            $("#editurl").val(data[4]);
        }
    });
4

1 回答 1

1

您只需要success处理程序中的以下内容:

var widget = uploadcare.Widget('#editurl');
widget.value(data[4]);

更多信息可以在JS API 文档页面上找到。

于 2015-10-06T10:55:46.020 回答