Saturday, 15 March 2014

php - Uploading file over https with cordova filetransfer -


I have found a problem with the file transfer plugin which I can not seem to know. My code works when I use http, but when I try to upload to https, it seems that this parameter does not send to my API, but it reaches my API. Only file is unavailable, the X-session-token header is present and valid. I use this file to upload files:

  $ scope.options = {}; $ Scope.options.fileKey = "file"; $ Scope.options.fileName = $ scope.img.substr ($ scope.img.lastIndexOf ('/') + 1); $ Scope.options.mimeType = "Image / JPEG"; $ Scope.options.headers = {'x-session-token': window.localStorage.auth}; // parameter: source, filepath, option $ cordovaFile.uploadFile ("https: / **** / api.php / profielpic /", $ scope.img, $ scope.options, true) then (function (result) {Console.log (results); $ cordovaToast.showShortTop ('gelukt Uploaden!') Then (function (success) {$ ionicLoading.hide () ;. $ state.go ('tab.profiel');}, function ( Error) {$ ionicLoading.hide (); $ state.go ('tab.profiel');})}}, function (error) {console.log (mistake); $ ionicLoading.hide ();});  

This is the code I use to see if the server side is anything:

  $ app-> Post ('/ profielpic /', function $ users = new API \ src \ user; $ authdata = json_decode ($ app- & gt; request & gt; headers- & gt; find ('x-) ($ apps) { $ Authentication = new API \ src \ authentication using session-token ')); $ Data = json_decode ($ app- & gt; request & gt; getBody ()); $ Userid = $ authdata-> UserID; $ Session_token = $ authdata-> Session_token; $ Userdata = $ data- & gt; Userdata; $ Alertsarray = array (); $ Message = null; $ If is = true $ authresult = $ auth-> Certified ($ userid, $ session_token); $ Imgname = time (); Print_r (json_encode ($ authdata)); Print_r (json_encode ($ _ files)); Print_r (json_encode ($ _ post)); Print_r (json_encode ($ data)); Print_r (json_encode (file_get_contents ("php: // input"))); / * If ($ authresult === true) {$ res = $ users-> updateUserPicture ($ userid, $ _FILES ['file']); If ($ res === incorrect) {$ isValid = false; $ Message = "er ging it's m."; } And {$ message = $ res; }} And {$ isValid = true; $ Message = $ authresult; } * / $ Data array = array ('isValid' = & gt; $ isValid, 'message' = & gt; $ message); Echo ")]} ', \ n" .json_encode ($ data array);  

});

But everything is empty with https: // If I upload to http: // then it works

Does anybody know why http works But is https not working? The only case where the https is not working, with the file upload, my remaining API routes work with https.

This happens on iOS devices and Android devices, so the problem is more likely to be with a thin API. I / O

API response: "32 \", "ResponseCode": 200, "Reaction": "{\" userID \ ": \" 2 \ ", \" session_token \ ": \" **** "} {\" name \ ": \" modified.jpg? 1427448587960 \ ", \" type \ ": \" image \\ / jpeg \ ", \" tmp_name \ ": \" \\ / tmp \\ / phpABKyF2 \ ", \" error \ ": 0, \" size \ ": \" \ ": 37,491}} [] inefficient \" \ ")]} ', \ n {\" if is \ ": true, \" message \ ": null}", "objectId": ""}

Make sure you are using a valid SSL certificate if access to your app API But not sending data, it is possible that your app has realized that the connection is insecure.

A self-signed certificate will not be trusted.


No comments:

Post a Comment