简体   繁体   中英

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?

More info about what i need

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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM