ralscha / blog

Source code for my blog
https://golb.hplar.ch/
MIT License
222 stars 246 forks source link

console.log(reader.result ) is {} #18

Closed yytian1017 closed 4 years ago

yytian1017 commented 6 years ago

Hello, I'm trying to apply your example to my ionic project,

2018-07-20 7 12 12

I console the reader.result, but it is {}. I don't the reason.

ralscha commented 6 years ago

No clue. Something worth trying is adding

<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com; style-src 'self' 'unsafe-inline'; media-src *">

to the index.html

see #16

yytian1017 commented 6 years ago

Thank you sir for your response. On android, my ionic app has successfully uploaded img to a server but when running on ios, the reader.result is {}.

when I add , ios buid failed

ralscha commented 6 years ago

Sorry. I have no idea what the problem is.

Can you try to listen for the load instead of the loadend event

reader.onload = () => {
ralscha commented 6 years ago

Here a list of all supported events
https://developer.mozilla.org/en-US/docs/Web/API/FileReader

yytian1017 commented 6 years ago

I really appreciate for your kind response. hmm..., I do nothing, but today it's work.