# Loading .env texture from input gives error "ERR\_INVALID\_URL"

**URL:** <https://forum.babylonjs.com/t/loading-env-texture-from-input-gives-error-err-invalid-url/28612>\
**Category:** Questions\
**Tags:** environment\
**Created:** [March 21, 2022, 9:43am UTC](https://forum.babylonjs.com/t/loading-env-texture-from-input-gives-error-err-invalid-url/28612 "2022-03-21T09:43:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![poshuk](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/poshuk/32/38718_2.png) [@poshuk](https://forum.babylonjs.com/u/poshuk)\
**Post date:** [March 21, 2022, 9:43am UTC](https://forum.babylonjs.com/t/loading-env-texture-from-input-gives-error-err-invalid-url/28612/1 "2022-03-21T09:43:17Z")

</div>

Hi  
when i try to load .env file it gives me err\_invalid\_url" for 6 cubemap images. here is the code

```auto
 const reader = new FileReader();
  reader.readAsDataURL(EnvFile);
  reader.onload = function () {
    const dataURL = reader.result;
    const envTexture = new BABYLON.CubeTexture(dataURL, scene);
    scene.createDefaultSkybox(envTexture, true, 10000);
  };

```

![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/e/c/ecbd3e75d8d96d6f2bf07460e29a21725b4e3fd8.png)

but when i try to load it though a link it works fine

Thanks for the help

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [March 21, 2022, 2:45pm UTC](https://forum.babylonjs.com/t/loading-env-texture-from-input-gives-error-err-invalid-url/28612/2 "2022-03-21T14:45:32Z")

</div>

Can you try to set the `forcedExtension` parameter of the CubeTexture constructor to “.env” in your code ?

Or the system will no be able to recognize it has to use the env loader.

---

<div class="post-metadata">

**Author:** ![poshuk](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/poshuk/32/38718_2.png) [@poshuk](https://forum.babylonjs.com/u/poshuk)\
**Post date:** [March 21, 2022, 3:44pm UTC](https://forum.babylonjs.com/t/loading-env-texture-from-input-gives-error-err-invalid-url/28612/3 "2022-03-21T15:44:02Z")

</div>

Thanks @sebavan, this worked  
This also solved my issue here:

```auto
      BABYLON.EnvironmentTextureTools.CreateEnvTextureAsync(cubeTexture)
        .then((buffer) => {
          var blob = new Blob([buffer], { type: "octet/stream" });
          var reader = new FileReader();
          reader.onload = function (evt) {
            var dataurl = evt.target.result;
            const envTexture = new BABYLON.CubeTexture(
              dataurl,
              scene,
              undefined,
              false,
              undefined,
              undefined,
              undefined,
              undefined,
              undefined,
              ".env"
            );
            scene.createDefaultSkybox(envTexture, true, 10000);
          };
          reader.readAsDataURL(blob);

```
