IOS Local File Upload


#1

hi,

I am facing the problem when i choose the file from iPad locad directory for upload. I cant able to upload file from iPad or iPhone local directory.but its working fine for iCloud file.

Is there any Solution?

many t.hanks


#2

Add some code please


#3

hi,

please refer my below code that i have used.


>  public ChooseFile() {   
>        let self1 = this;    
>        if (this.platform.is('ios')) { 
>           FilePicker.pickFile(uri => {       
>                this.choosenfilepath = uri       
>                this.filecontentsize = true;      
>           }, 
>        function (error) {       
>        self1.presentalert(JSON.stringify(error));     
>      },        
>      function (sucess) {
>         })    
>  }    
>    if (this.platform.is('android')) {     
>      let self = this;      
>    this.fileChooser.open().then((url) => {   
>       (window as any).resolveLocalFileSystemURI(url, function (fileEntry) {    
>          fileEntry.file(function (fileObj) {      
>            var maxfilesize = 1024 * 1024 * 20;     
>            if (maxfilesize > fileObj.size) {       
>           self.filecontentsize = true;     
>         }          
>    });        
>  });       
>    if (url.startsWith('raw:/')) {       
>        url.replace("raw:/", "");      
>    }      
>    this.filepath.resolveNativePath(url).then(result => {    
>        this.choosenfilepath = result;      
>    })         
>   .catch(err => {     
>         this.choosenfilepath = url;       
>         self.presentalert(JSON.stringify(err));      
>        })    
>    })       
>   .catch(err => {    
>        this.presentToastss('error ocuured during opning file');   
>       })   
>     } 
>   }

Thanks


#4

and what the error you get?


#5

not getting any error but when i am going to choose file in iPad there is a no option available for choose file from iPad local directory (from iPad).
where as i am able to choose file from iCloud but not for local file.


#6

this way look like the old way please see docs

constructor(private filePicker: IOSFilePicker) { }

...

this.filePicker.pickFile()
  .then(uri => console.log(uri))
  .catch(err => console.log('Error', err));

#7

i have tried this but its not working. Still i am not able to choose file from local directory.


please see attachment

there is 4 options

  1. On my iPad
  2. iCloud Drive
  3. Dropbox
  4. Recently Deleted

but there is a no more option for local directory like (File Manager , Gallary).


#8

Thats because you can’t. You can if you use the html file input <input type="file>