这个PHP脚本非常适合音频文件,但当我更改它以处理视频文件时,它会不断向我发送"这是不允许的错误"。这是我的代码:
$file = $_POST['filev'];
$fileName = $_FILES['filev']['name'];
$fileTmpName = $_FILES['filev']['tmp_name'];
$fileSize = $_FILES['filev']['size'];
$fileError = $_FILES['filev']['error'];
$fileType = $_FILES['filev']['type'];
$fileExt = explode('.', $fileName);
$fileActualExt = strtolower(end($fileExt));
$allowed = array('mp4', 'MP4', 'mpeg', 'wmv', 'ogg', 'webM', 'mov', 'swf');
if (in_array($fileActualExt, $allowed)) {
if ($fileError === 0) {
if ($fileSize < 75000000000000000) {
$fileNameNew = uniqid('', true).".".$fileActualExt;
//insert post
$fileDestination = 'uploads/'.$fileNameNew;
move_uploaded_file($fileTmpName, $fileDestination);
$query = mysqli_query($this->con, "INSERT INTO posts
VALUES('', '$fileDestination', '$added_by', '$user_to', '$date_added', 'no',
'no', '0')");
$returned_id = mysqli_insert_id($this->con);
//update post count for user
$num_posts = $this->user_obj->getNumPosts();
$num_posts++;
$update_query = mysqli_query($this->con, "UPDATE
users SET num_posts='$num_posts' WHERE username='$added_by'");
header("Location: video.php?success");
} else {
echo "Your file is too big";
}
} else {
echo "There was an error uploading your file";
}
}
else {
echo "This is not allowed";
}
我试图上传的文件是一个mp4文件,但它仍然给了我&#34;这是不允许的错误&#34;,即使我把它包含在$ allowed变量中。任何对我的问题的帮助将不胜感激。
答案 0 :(得分:-1)
尝试将.flv放在$ allowed变量
上