EMRADE
EMRADE

Reputation: 183

Ionic 3 Cordova File plugin gives error for copyFile operation

I am trying to copy a file from one dir to another using the copyFile(path, fileName, newPath, newFileName) function. It gives an error like {"code":13, "message":"input is not a directory"}. The documentation has only 12 error code and no 13th. I'd like to know what i did wrong please.

Here is a sample of my actual code.

this.path = "file:///storage/emulated/0/TheFolder/thefile.ext";
this.newPath = "file:///storage/emulated/0/NewFolder";

this.fileCtrl.copyFile(this.path, fileName, this.newPath, newFileName)

Upvotes: 3

Views: 3063

Answers (1)

SABDAR SHAIK
SABDAR SHAIK

Reputation: 671

this.path must be a directory but your are showing some file name

change your code as follows

this.path = "file:///storage/emulated/0/TheFolder";
this.newPath = "file:///storage/emulated/0/NewFolder";

this.fileCtrl.copyFile(this.path, YOUR_EXISTING_FILE_NAME, this.newPath, NEW_FILE_NAME);


path -Base FileSystem
fileName - Name of file to copy
newPath - Base FileSystem of new location
newFileName - New name of file to copy to (leave blank to remain the same)

Upvotes: 4

Related Questions