cordova - PhoneGap file upload 3G -
i'm experiencing annoying problem phonegap. i've created app uploads image remote server (server runs php).
when upload image via wifi app works when upload same image via 2g/3g nothing happens. there no error callback, no success callback, nothing happens @ all.
i've tried different file sizes including small (~150kb) files , doesn't seem help/matter. i've tried cordova version 2.5, 2.6 , 2.7. app uses default example phonegap docs. app code is:
var app = { // application constructor initialize: function() { this.bindevents(); }, // bind event listeners // // bind events required on startup. common events are: // 'load', 'deviceready', 'offline', , 'online'. bindevents: function() { document.addeventlistener('deviceready', this.ondeviceready, false); }, // deviceready event handler // // scope of 'this' event. in order call 'receivedevent' // function, must explicity call 'app.receivedevent(...);' ondeviceready: function() { app.receivedevent('deviceready'); }, // update dom on received event receivedevent: function(id) { var parentelement = document.getelementbyid(id); var listeningelement = parentelement.queryselector('.listening'); var receivedelement = parentelement.queryselector('.received'); listeningelement.setattribute('style', 'display:none;'); receivedelement.setattribute('style', 'display:block;'); console.log('received event: ' + id); }, dostuff: function() { navigator.camera.getpicture(app.uploadphoto, function(message) { alert('get picture failed'); }, { quality: 50, destinationtype: navigator.camera.destinationtype.file_uri, sourcetype: navigator.camera.picturesourcetype.photolibrary } ); }, uploadphoto: function(imageuri) { var options = new fileuploadoptions(); options.filekey="files"; options.filename=imageuri.substr(imageuri.lastindexof('/')+1); options.mimetype="image/jpeg"; var params = {}; params.pathname = "variable_for_server"; params['file-type'] = 'image'; options.params = params; try { var ft = new filetransfer(); ft.upload(imageuri, encodeuri("server_url_here"), app.win, app.fail, options, true); } catch (err) { console.log('catch error'); console.log(err); } }, win: function(r) { console.log("code = " + r.responsecode); console.log("response = " + r.response); console.log("sent = " + r.bytessent); }, fail: function(error) { alert("an error has occurred: code = " + error.code); console.log("upload error source " + error.source); console.log("upload error target " + error.target); } };
on server $_files variable empty. have idea going on here because i'm going crazy trying fix/debug :d
Comments
Post a Comment