Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/389.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/290.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 未使用xhr发布视频blob数据_Javascript_Php_Html - Fatal编程技术网

Javascript 未使用xhr发布视频blob数据

Javascript 未使用xhr发布视频blob数据,javascript,php,html,Javascript,Php,Html,我正在使用rtcmulticonnection.js。我想在服务器上保存视频。这里有两个文件“index.html”和“save.php”。 request.open(“POST”,url)不发布数据 这里是源文件链接 “” index.html document.getElementById('recordAudioVideo').onclick = function() { var localVideoStream = rmc.streams.selectFirst({

我正在使用rtcmulticonnection.js。我想在服务器上保存视频。这里有两个文件“index.html”和“save.php”。
request.open(“POST”,url)不发布数据
这里是源文件链接
“”

index.html

document.getElementById('recordAudioVideo').onclick = function() {
    var localVideoStream = rmc.streams.selectFirst({
        video: true,
        local: true
    });
    if (!localVideoStream) return;
    var recordingSession = {
        audio: true,
        video: true
    };
    var button = this;
    if (button.innerHTML == 'Record Audio/Video') {
        button.innerHTML = 'Stop Recording Audio/Video';
        // http://www.rtcmulticonnection.org/docs/startRecording/
        localVideoStream.startRecording(recordingSession);
    } else if (button.innerHTML == 'Stop Recording Audio/Video') {
        // http://www.rtcmulticonnection.org/docs/stopRecording/
        localVideoStream.stopRecording(function(blob) {
            //alert('Audio blob size in bytes: ' + blob.audio.size);
            //alert('Video blob size in bytes: ' + blob.video.size);
            var fileType = 'video'; // or "audio"
var fileName = 'ABCDEF.webm';  // or "wav"

var formData = new FormData();
formData.append(fileType + '-filename', fileName);
formData.append(fileType + '-blob', blob);
console.log(formData);
xhr('save.php', formData, function (fName) {
    window.open(location.href + fName);
});

function xhr(url, data, callback) {
    var request = new XMLHttpRequest();
    request.onreadystatechange = function () {
        if (request.readyState == 4 && request.status == 200) {
            callback(location.href + request.responseText);
        }
    };
    request.open("POST", url);
    request.send(data);
}
            button.innerHTML = 'Record Audio/Video';
        }, recordingSession);
    }
save.php

<?php
// Muaz Khan     - www.MuazKhan.com 
// MIT License   - https://www.webrtc-experiment.com/licence/
// Documentation - https://github.com/muaz-khan/WebRTC-Experiment/tree/master/RecordRTC
foreach(array('video', 'audio') as $type) {
    if (isset($_FILES["${type}-blob"])) {

        echo 'uploads/';

        $fileName = $_POST["${type}-filename"];
        $uploadDirectory = './'.$fileName;

        if (!move_uploaded_file($_FILES["${type}-blob"]["tmp_name"], $uploadDirectory)) {
            echo(" problem moving uploaded file");
        }

        echo($fileName);
    }
}
?>
request.open(“POST”,url)
不会发布数据。它不会调用
url(意思是save.php)
。因为我有一些文本提醒我是否调用了save.php。所以它不会在客户端上显示任何alertbox。我如何解决这个问题。它也不会在发布时显示任何错误

request.open("POST", url);
request.send(data);