RESTful 在 PHP 中上传视频文件

RESTful uploading of a video file in PHP

我想使用 POST 请求将视频文件上传到服务器。网上关于它的资料不多。

我通常会使用此代码检查我发送的数据

$params = $_REQUEST;
return $params;

我在 POSTMAN 中查看。我有 table 叫 video_review

编号 video_url movie_id user_id date_time

当我选择一个视频文件并单击发送时,我希望将视频文件的位置保存到 video_url 字段中。但是在控制器中,当我 运行 这段代码 return $params; 我什么也得不到。

编辑

取得了一些进展

public function actionCreate_video_review()
    {

        $allowedExts = array("jpg", "jpeg", "gif", "png", "mp3", "mp4", "wma","mkv");
$extension = pathinfo($_FILES['video_url']['name'], PATHINFO_EXTENSION);


if (  ($_FILES["video_url"]["type"] == "video/mp4")|| ($_FILES["video_url"]["type"] == "video/x-matroska")

&& ($_FILES["video_url"]["size"] < 20000)
&& in_array($extension, $allowedExts) )

  {
  if ($_FILES["video_url"]["error"] > 0)
    {
    return   $_FILES["video_url"]["error"];
    }
  else
    {

    if (file_exists("upload/" . $_FILES["video_url"]["name"]))
            {
                echo $_FILES["video_url"]["name"] . " already exists. ";
            }
            else
            {
                move_uploaded_file($_FILES["video_url"]["tmp_name"],
                "upload/" . $_FILES["video_url"]["name"]);
                echo "Stored in: " . "upload/" . $_FILES["video_url"]["name"];
                return $_FILES["video_url"]["name"];
            }
}}

我成功了。

 //POST Video Reviews
    public function actionCreate_video_review()
    {

        $allowedExts = array("jpg", "jpeg", "gif", "png", "mp3", "mp4", "wma","mkv");
        $extension = pathinfo($_FILES['video_url']['name'], PATHINFO_EXTENSION);

        if (  ($_FILES["video_url"]["type"] == "video/mp4")|| ($_FILES["video_url"]["type"] == "video/x-matroska")&& ($_FILES["video_url"]["size"] < 90000) && in_array($extension, $allowedExts) )
        {
            if ($_FILES["video_url"]["error"] > 0)
            {
                return   $_FILES["video_url"]["error"];
            }
            else
            {

                if (file_exists("upload/" . $_FILES["video_url"]["name"]))
                {
                    echo $_FILES["video_url"]["name"] . " already exists. ";
                }
                else
                {
                    $model = new \app\models\VideoReview();
                    $model->video_url = $_FILES["video_url"]["name"];
                    $model->save();
                    move_uploaded_file($_FILES["video_url"]["tmp_name"],
                        \Yii::$app->basePath. '/web/uploads/' . $_FILES["video_url"]["name"]);

                        return $_FILES["video_url"]["name"];
                    }
                }
            }
            else
            {
                return   $_FILES["video_url"]["error"] ."Error";   
            }
}