@muizzjames wrote:
Hello. everyone. I am a new ionic programmer. I have created a new ionic project. The goal of project is to write png file to android phone. So I have install ngCordova plugin and CordovaFile plugin in my project. And Then I have writed my code.
The canvas already have a one image.
var v_canvas = document.getElementById("canvas"); var imageData = v_canvas.toDataURL().replace(/data:image\/png;base64,/,''); // WRITE $cordovaFile.writeFile("file:///storage/sdcard0/", "test_1.png", imageData, true) .then(function (success) { // success //console.log("path = " + cordova.file.dataDirectory); console.log("<<<<<<<< : write file ok"); }, function (error) { console.log("<<<<<<<< : write file error"); // error });
surely , the file(test_1.png) was created on my phone. But the png file is not valid. I can't open the png file on my phone using gallery. What's the problem? Please anyone help me. Thanks.
Posts: 1
Participants: 1