# Check whether file exist in mobile storage or not

**URL:** <https://forum.ionicframework.com/t/check-whether-file-exist-in-mobile-storage-or-not/88160>\
**Category:** ionic-v3\
**Created:** [April 28, 2017, 6:36am UTC](https://forum.ionicframework.com/t/check-whether-file-exist-in-mobile-storage-or-not/88160 "2017-04-28T06:36:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vks\_gautam1](https://avatars.discourse-cdn.com/v4/letter/v/ed655f/32.png) [@vks\_gautam1](https://forum.ionicframework.com/u/vks_gautam1)\
**Post date:** [April 28, 2017, 6:36am UTC](https://forum.ionicframework.com/t/check-whether-file-exist-in-mobile-storage-or-not/88160/1 "2017-04-28T06:36:51Z")

</div>

i am using file plugin . although files are in mobile storage and loading on device image src but  
if i use this code showing “files not found”.  
ionic 2.2.0

```auto
 for (let i = 0; i < data.rows.length; i++) {
            console.log(data.rows.item(i).local)
            File.checkFile(cordova.file.dataDirectory, data.rows.item(i).local).then(
              (files) => {
                console.log("files found" + files)
                resolve()
              }
            ).catch(
              (err) => {
                console.log("files not found ")
              }
              );

```

---

<div class="post-metadata">

**Author:** ![vks\_gautam1](https://avatars.discourse-cdn.com/v4/letter/v/ed655f/32.png) [@vks\_gautam1](https://forum.ionicframework.com/u/vks_gautam1)\
**Post date:** [April 28, 2017, 7:17am UTC](https://forum.ionicframework.com/t/check-whether-file-exist-in-mobile-storage-or-not/88160/2 "2017-04-28T07:17:01Z")

</div>

my file path is like this

“file:///storage/emulated/0/Android/data/com.ionicframework.schoolmgtsystem274373/image\_1.jpg”

---

<div class="post-metadata">

**Author:** ![vks\_gautam1](https://avatars.discourse-cdn.com/v4/letter/v/ed655f/32.png) [@vks\_gautam1](https://forum.ionicframework.com/u/vks_gautam1)\
**Post date:** [April 28, 2017, 8:34am UTC](https://forum.ionicframework.com/t/check-whether-file-exist-in-mobile-storage-or-not/88160/3 "2017-04-28T08:34:42Z")

</div>

there was mistake in my side because in this it should be  
File.checkFile(filepath, filename).  
this is working for me

```auto
 for (let i = 0; i < data.rows.length; i++) {
            console.log(data.rows.item(i).local)
 let path: string = data.rows.item(i).local;
            // path=path.split('//')[1];
            console.log(data.rows.item(i).local)
            let filepath = path.substring(0, path.lastIndexOf('/') + 1);
            let filename = path.substring(path.lastIndexOf('/') + 1, path.length);
            File.checkFile(filepath, filename).then(
              (files) => {
                console.log("files found" + files)
              }
            ).catch(
              (err) => {
                console.log("files not found ")
              }
              );

```
