我有一个PHP脚本。该剧本无法上传视频。
当我提交表单时,我收到错误:警告:getimagesize():文件名不能为空。我在互联网上搜索,我在文件()和$ _FILES [" uploaded_file"] [" type"]中更改了getimagesize。 但这不起作用。
有人能帮助我吗?如何将视频上传到upload_video文件夹? 插入到数据库中的工作正在进行中。
我的脚本是:
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);
答案 0 :(得分:0)
getimagesize()用于确定任何给定图像文件的大小,并返回尺寸和文件类型。
这里没有使用getimagesize()。从代码中清除它。它可能有用。