我有一个上传视频表单,上传一个小的 avi 文件时效果很好。这是我的 php 代码,用于将视频放在我选择的文件夹中
$path = pathinfo($_FILES["file"]["name"]);
$ext = $path['extension'];
if ($ext == "avi" || $ext == "mp4" || $ext == "mpg" || $ext == "mov" || $ext == "wmv" || $ext == "flv"){
if ($_FILES["file"]["error"] > 0){
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
}
else{
echo "Upload: " . $_FILES["file"]["name"] . "<br />";
echo "Type: " . $_FILES["file"]["type"] . "<br />";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";
if (file_exists("videos/" . $_FILES["file"]["name"])){
echo $_FILES["file"]["name"] . " already exists. ";
echo "<a href = './videochannel.php'>Return to Channel</a>";
}
else{
move_uploaded_file($_FILES["file"]["tmp_name"],"videos/" . $_FILES["file"]["name"]);
echo "Stored in: " . "videos/" . $_FILES["file"]["name"];
echo "<a href = './videochannel.php'>Return to Channel</a>";
}
}
}
else{
echo "That is not a supported file type. Please try again. <a href = './videochannel.php'>Return to Channel</a>";
}
?>
但是,当我上传 mp4 时,我得到“返回代码 1”,如果我没记错的话,这与我在 php.ini 中更改为 200M 的最大上传大小有关。它仍然没有工作。这也表示在上传任何其他选项时它不是受支持的文件类型。