Hi!
I'm trying to set the TWebImageControl image from a mobile picture gallery or camera. I see no WEB Core to do this, so I'm trying to do it via JS, but I ecountered some problems:
This JS code works OK, but don't know where/how to put it in the form code:
Contol on the form TWebHtmlContainer
<label class="btn btn-xl btn-success">
Add picture <input type="file" hidden name="imgFile" accept="image/gif, image/jpeg, image/png, image/bmp, image/tiff, image/tif, image/jfif, image/jpe">
</label>
JS that works in a test form (outside the project)
<script>
$(":file").change(function () {
if (this.files && this.files[0]) {
var reader = new FileReader();
reader.onload = imageIsLoaded;
reader.readAsDataURL(this.files[0]);
}
});
function imageIsLoaded(e) {
$('img').attr('src', e.target.result);
$('img').fadeIn();
};
</script>
You can test it here: https://jsfiddle.net/KyleMit/d3H9f/
How to do this with web core? Or alternatively - how to add JS to the form so it will accept images?