#loading an image based on user input (electron-vue, webpack build tool)
74 messages · Page 1 of 1 (latest)
input type="file"
so?
read the article
am reading it
i tried to use the FileReader to read the img but i got : Error: Cannot find module 'original-fs'
but when i try access it via the console i found it 😩
i don't know why am getting this error
i dont know either
remove incorrect imports from your code
true
an imported by vsCode which i didn't notice
it worked perfectly , now when i should store the image path in the db however the FileReader take the whole files[0], should store it as a json in the db ?
thanks for helping
how familiar you with web and js?
good enough i think
then what path, what db, why is take files[0] and why json?
and why you use FileReaded
to read the file
i know the readAsDataURL takes the file instance as an argument, so passing only the file path will not work , that's why i asked in which form should store the file
i know i can store a file ref 'file path' read it on the mainProcess using fs then send the file instance to renderer and read it using FileReader...
i was looking for something shorter only
you cant pass file via ipc
so what to do ?
hahah sorry bro i disturbed you
that is the scenario :
user select an image for 'membership info'
i used the fileReader to display it,
when user confirm the membership i take the form data 'including the selected image ' and store theme in the db
know when fetching data and displays the members how to display those images
saying that import() method will not work
to display it you need only path to file
the images needs to be loaded dynamicaly
what do you mean by dynamicaly?
you can load any image by changing src attribute
any time
bro you said i need only a path ? ok
when the user select an image i take that path and set it to img src attr, the app throw an error
what error?
well thats becase browser not allowed to load local files from web server by security reasons
yes i know
it's electron
is there a work around
without changing securtiy settings ?
basicaly it's offline but i want to add some auto update
i mean from where you load web page
offline
if you load it from dev web server
in development
you can disable security for development
because when you start to load it from file protocol error goes away
in production it's load from file protocol ?
now build it
and
for development you can add to webPreferences webSecurity: !app.isPackaged