EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: slavok47 on June 19, 2022, 05:42:16 AM



Title: Open image with easyui-filebox
Post by: slavok47 on June 19, 2022, 05:42:16 AM
Hello everyone, tell me how to open an image in
Code:
<img id="myImg">
using easyui-filebox, I can’t figure something out


Title: Re: Open image with easyui-filebox
Post by: slavok47 on June 19, 2022, 10:47:23 AM
Did this
Code:
$('#addFileBox').filebox({
onChange: function(value){
$('#imagePack').attr('src', value);
}
});
but the problem is that only the file name is indicated, but the full path is needed


Title: Re: Open image with easyui-filebox
Post by: jarry on June 19, 2022, 08:18:47 PM
Please refer to the code below.
Code:
$('#addFileBox').filebox({
onChange: function(value){
var id = $(this).filebox('options').fileboxId;
var files = $('#'+id)[0].files;
if (files.length){
var url = window.URL.createObjectURL(files[0]);
$('#myImg').attr('src', url);
}
}
})


Title: Re: Open image with easyui-filebox
Post by: slavok47 on June 20, 2022, 08:11:11 AM
Thank you, everything works, but only the second time, the first time does not work