Hi i am trying to store object to my mobile file system, by creating a file and read or overwrite that file when needed i could able to create file or folder using cordova file plugin. but when i try to create a file with .txt extension i get err in my console "resources interrupted as script but started as MIME type text/plane ". if i remove .txt extension file gets created.
What i need is to create a file that has the user data and store it to mobile filesystem could someone help me
import { Component } from '@angular/core';
import { NavController, NavParams } from 'ionic-angular';
import { File } from 'ionic-native';
declare var cordova: any;
@Component({
selector: 'page-login',
templateUrl: 'login.html'
})
export class LoginPage {
user = {
Name: '',
email: '',
phone: '',
Country: ''
};
constructor(public navCtrl: NavController, public navParams: NavParams) {}
Upload(){
console.log("upload button clicked",this.text);
}
create(){
console.log("create");
File.createFile(cordova.file.externalRootDirectory , "file.txt", true)
.then(function (success) {
// success
console.log("folder created", success);
}, function (error) {
// error
console.log("folder not created", error)
});
}
writeFile(){
console.log("write to file");
var root = cordova.file.externalRootDirectory;
var path = root + "/myFolder"
var text = JSON.stringify(this.user);
File.writeFile(path , "file.txt", "text", true)
.then(function (success) {
// success
console.log("folder created", success);
}, function (error) {
// error
console.log("folder not created", error)
});
}
}