Uploading file over https

I’ve got a problem with the file transfer plugin that i can’t seem to figure out. My code works when i’m using http, but when I try to upload over https it seems that it doesn’t send the parameters to my api but it does reach my api. only the the file is missing, the x-session-token header is present and valid. This is the code i use for uploading the file:

$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

// parameters: source, filePath, options
$cordovaFile.uploadFile("https:/****/api.php/profielpic/", $scope.img, $scope.options, true).then(function(result) {
  $cordovaToast.showShortTop('Uploaden gelukt!').then(function(success) {
  }, function (error) {

}, function(err) {

This is the code i use Server side to see if there’s anything:

$app->post('/profielpic/', function () use ($app) {

$auth           = new api\src\Auth;
$users          = new api\src\Users;
$authdata       = json_decode($app->request->headers->get('x-session-token'));
$data           = json_decode($app->request->getBody());
$userid         = $authdata->userID ;
$session_token  = $authdata->session_token;
$userdata       = $data->userdata;
$alertsarray    = array();
$message        = null;
$isValid        = true;
$authresult     = $auth->authenticate($userid, $session_token);

$imgname = time();
if($authresult === true) {
    $res = $users->updateUserPicture($userid, $_FILES['file']);
    if($res === false) {
        $isValid = false;
        $message = "Er ging iets mis.";
        $message = $res;
}else { 
    $isValid = true;
    $message = $authresult; 

$dataArray = array(
    'isValid' => $isValid,
    'message' => $message

echo ")]}',\n".json_encode($dataArray);

but everything is empty with https:// if i upload to http:// it works

Does anyone know why http works but https isn’t working? the only case where https isn’t working is with file uploads. the rest of my api routes work with https.

It happens on iOS devices and Android devices so the problem is more likely to be with the slim api i’d guess

Api response:
{ "bytesSent": 32889, "responseCode": 200, "response": "{\"userID\":\"2\",\"session_token\":\"****" } {\ "file\":{\"name\":\"modified.jpg?1427448587960\",\"type\":\"image\\/jpeg\",\"tmp_name\":\"\\/tmp\\/phpABKyF2\",\"error\":0,\"size\":37491}}[]null\"\")]}',\n{\"isValid\":true,\"message\":null}", "objectId": "" }

Can’t seem to find what is happening

This still is an issue for me. Is it impossible to send over https or something? Can’t seem to find any other topics about it.

Oke so i just solved this. It worked for a http but for https you need to add these 2 options:

$scope.options.chunkedMode = false; $scope.options.httpMethod = "POST";

1 Like

@sjerd thanks bro i was having same problem.