nativescript-background-http上传文件到php

I want to upload audio file on my server using nativescript-background-http plugin. The mobile side is working fine. no runtime error. The log shows complete upload but when I visit the directory on my server, no file is uploaded.

Here's my code on nativescript

var session = bghttp.session("image-upload");
var audioFolder = fs.knownFolders.documents().getFolder("audio");
var recordedFile = audioFolder.getFile("recording.mp3");
var request = {
    url: "http://talktext.me/talktext.me(app)/recAudio.php",
    method: "POST",
    headers: {
        "Content-Type": "application/octet-stream",
        "File-Name": "recording.mp3"
    },
    description: "{ 'uploading': '" + "recording.mp3" + "' }"
};
alert(recordedFile.path);
let params = [
            { name: "test", value: recordedFile.path },
            { name: "fileToUpload", filename: recordedFile.path, mimeType: 'audio/mpeg' }
];
var task = session.multipartUpload(params, request);

task.on("progress", logEvent);
task.on("error", logEvent);
task.on("complete", logEvent);
function logEvent(e) {
   console.log("UPLOAD STATUS: "+e.eventName);

}

Here's my code on recAudio.php

$all_headers = apache_request_headers();
$newimg = file_put_contents('uploads/' . $all_headers['File-Name'], 
file_get_contents('php://input'));

Everything on mobile is working fine. But no file is uploaded on the server.

I'm not a PHP expert but I used to work on it a long time ago. Looks like php://input is not available for multipart uploads.

Source: http://php.net/manual/en/wrappers.php.php

make sure header available to the application in .htaccess file of the server

RewriteCond %{HTTP:File-Name} .
RewriteRule .* - [E=HTTP_FILENAME:%{HTTP:File-Name}]

use like

file_put_contents('uploads/' . $_SERVER['HTTP_FILENAME'],file_get_contents('php://input'));