'apperyio, ionic5, input[type=file], load image asset to the image
I'm trying to load an image from the input[type=file] to the image on a page. Is it possible to do it without uploading a file to the database?
Solution 1:[1]
Here is a solution for this, i've got with a help of Ravi(thanks to him).
1 Create a "fileURL" variable. How to do it
2 On image set "src" attribute with value of "{{fileURL}}". How to do it
3 Click on "file" and add "change" evet -> run typescript, with code How to do it:
//event.target.firstChild - is an input.
let file = event.target.firstChild.files[0];
if(file)
this.fileURL = URL.createObjectURL(file);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | John802 |
