don/cordova-filechooser

File (.pdf) path directory doesn't exist error if I select file (.pdf) from mobile download folder in ionic.

pradeep531 opened this issue · 0 comments

I everyone,
I want to upload the pdf file on our server using the file-chooser Cordova plugin. I had success in the file selection but after the file selection I tried to upload on the server but received the error "directory doesn't exist".

`var filter = { "mime": "application/pdf" };
this.fileChooser.open(filter)
.then(url => {
console.log('fileChooser:',url);
this.filePath.resolveNativePath(url)
.then(filePath => {
console.log('saif file pathhh',filePath);
let correctPath = url.substr(0,url.lastIndexOf("/") + 1);
let currentName = filePath.substring(filePath.lastIndexOf('/') + 1);

          this.file.checkDir(this.file.externalDataDirectory, correctPath).then(_ => console.log('Directory exists')).catch(err =>
            console.log('Directory doesnt exist'));

            
          
          let _filePath = filePath;
          let resPath = this.pathForImage(_filePath);

          let newEntry = {
            name: currentName,
            path: resPath,
            filePath: _filePath,
            comparessedPath: _filePath,
          };

          this.startUpload(newEntry, index, field_id);


      })
      .catch(err => console.log('saif file pathhh errorrr',err));
  })
  .catch(e => {
    console.log('saif file pathhh errorrr catchhh',e);
  });`