PHP 视频上传不起作用


php video upload doesn't work

我有一个php脚本。脚本无法上传视频。

当我提交表单时,我收到错误:警告:getimagesize():文件名不能为空。我在互联网上有搜索,我在 file() 和 $_FILES["uploaded_file"]["类型"]中更改了 getimagesize;但这行不通。

有人可以帮助我吗?如何将视频上传到upload_video文件夹?插入到 de 数据库中正在工作。

我的脚本是:

include 'connect.php';
$target_dir = "upload_video/";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
$uploadOk = 1;
$imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
var_dump($imageFileType);
if(isset($_POST["submit"])) {
    $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);//this is wrong  
}
if (file_exists($target_file)) {
    echo "Sorry, file already exists.";
    $uploadOk = 0;
}
if($imageFileType != "mp4" ) 
{
    echo "only mp4 extensions";
    $uploadOk = 0;
}
if ($uploadOk == 0) {
    echo "Sorry, your file was not uploaded.";
} else {
    if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
        echo "the video ". basename( $_FILES["fileToUpload"]["name"]). " is upload.";
    } else {
        echo "Sorry, there was an error uploading your file.";
    }
}
$sql = "INSERT INTO upload_video (file, description)VALUES (?, ?)";
$stmt = $link->prepare($sql);
$stmt->bind_param("ss", $target_file, $description );
 $beschrijving = $_POST['beschrijving'];
$stmt->execute();

if ($sql) {
} else{
    echo "Data not add";
    }
$stmt->close();
mysqli_close($link); 

getimagesize() 用于确定任何给定图像文件的大小并返回尺寸和文件类型。

这里没有使用 getimagesize()。从代码中清除它。它可能会起作用。