- Home /
Is there a way to load images into a WebGL app?
I need to let the user select an image they have taken with their phone and load it into a Web GL app. I thought this would be a simple task but with Web GL the WWW-class seems to not be able to load from the local harddrive.
So I thought maybe they could upload their image to dropbox or something and access the url using WWW. This works fine in editor but not with a compiled Web GL app. Because reasons
Is there any way that I can have a user load images into a WebGL app???
EDIT: I suspect that if one could load a texture using jslib it would be possible? If someone could provide an example that would be awesome!
Answer by Mikael-H · Nov 09, 2016 at 12:32 PM
Yes, there is indeed a few ways to accomplish this as explained by the awesome Alex Suvorov in this thread on Unity Forums
In short you create a javascript plugin and call it using System.Runtime.InteropServices
There are a few different approaches and piitfalls so you really should read all the entries in the thread, at least those written by Alex.
Answer by ToruTheRedFox · Jan 25, 2020 at 12:10 PM
I myself have solved this by getting the browser to use a javascript that downloads the required image as a byte array, and converts that to a Base64 string, which it then passes to a function in the game instance that decodes the string into a byte array and uses ImageConversion.LoadImage() on it
Your answer
![](https://koobas.hobune.stream/wayback/20220612060446im_/https://answers.unity.com/themes/thub/images/avi.jpg)