lundi 2 novembre 2015

Record video and store it in to storage folder in Laravel

In my Laravel project I have to integrate a module that is, record live video and save it in to storage folder in Laravel. So I have downloaded a library RecordRTC-to-PHP

I have tested this in simple PHP. It works fine. But I stuck to include this in my Laravel project. Please check below code and help me to convert simple PHP code to Laravel5 code.

JS

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);

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);
}

PHP

<?php
foreach(array('video', 'audio') as $type) {
    if (isset($_FILES["${type}-blob"])) {

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

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

        echo($uploadDirectory);
    }
}
?>

Laravel Controller

public function store(RecordingvideoRequest $request)
    {
        $file   = $request->file("video-blob");
        dd($file);
    }

In controller result is showing null



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire