Cordova Android app, file_not_found when trying to upload to remote server -
i trying upload file remote server using cordova android application, can resolve url of file path , can print path of file can find file , exist. whenever go upload file keeps failing error code of 1 means file not found. file located on sd card , create using app. here code uploading file.
function upload() { window.resolvelocalfilesystemurl( "file:///storage/emulated/0/testfile5.txt", gotfileaddress, error); } function error() { alert("no file"); } function gotfileaddress(fileentry) { fileurl = fileentry.tourl(); server = encodeuri("http://test.server.com/upload"); alert(fileurl) var options = new fileuploadoptions(); options.filekey = "file"; options.filename = fileurl.substr(fileurl.lastindexof('/') + 1); options.mimetype = "text/plain"; alert("a"); var params = {}; params.value1 = "test"; params.value2 = "param"; alert("b"); options.params = params; alert("c"); var ft = new filetransfer(); ft.upload(fileurl, server, win, fail, options); alert("d"); function win(r) { console.log("code = " + r.responsecode); console.log("response = " + r.response); console.log("sent = " + r.bytessent); } function fail(error) { alert("an error has occurred: code = " + error.code); alert("upload error source " + error.source + " \n upload error target " + error.target); } } // end of upload
has suggestions ? have been stuck on ages
Comments
Post a Comment