EasyUI Forum
March 28, 2024, 01:36:27 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Open image with easyui-filebox  (Read 1752 times)
slavok47
Newbie
*
Posts: 7


View Profile Email
« 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
Logged
slavok47
Newbie
*
Posts: 7


View Profile Email
« Reply #1 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
Logged
jarry
Administrator
Hero Member
*****
Posts: 2260


View Profile Email
« Reply #2 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);
}
}
})
Logged
slavok47
Newbie
*
Posts: 7


View Profile Email
« Reply #3 on: June 20, 2022, 08:11:11 AM »

Thank you, everything works, but only the second time, the first time does not work
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!