Loading Image From File Path Using WWW MalFormedURLException

Hello,

I’m trying to create an applicaiton using unity that allows users to select a picture from their gallery to be loaded into the app. I’m using the following code below in a coroutine, but I keep getting a MalFormedURLException. This is the file path I’m trying to access, “/storage/extSdCard/DCIM/Camera/20141130_190635.jpg”, and if I follow that on my test phone I can find the image. Is there some something I need to add to the file path to get the image to load correctly?

WWW lWWW = new WWW( lImagePath );

while (!lWWW.isDone)
{
yield return new WaitForSeconds( 0.2f );
}

Texture2D lLoadedTexture = lWWW.texture;

Thanks!

WWW takes URL as a parameter not a file path. You need to convert your file path into a URL before passing it to WWW.

I was able to get it working by prefixing the file path with “file://”