我已经更改了php.in配置,其中设置了max_size = 256M,但它仍然不允许我上传。我不知道我哪里错了.....我能够上传图像文件,pdf文件,纪录片文件,但不能上传mp3。 php.in设置对我没有用...请任何人都可以指导我。下面是我的PHP代码
提前致谢!
<?php
//Concept of file upload
if(isset($_POST['submit']))
{
$file = $_FILES['files']['name'];
$type = $_FILES['files']['type'];
$file_tmp = $_FILES['files']['tmp_name'];
$size = $_FILES['files']['size'];
$file_err = $_FILES['files']['error'];
if($size!=null)
{
if($_FILES['files']['size'] <= 10000000 && $_FILES['files']['type'] == "audio/mpeg")
{
$path = "D:/";
$path = $path.basename($file);
if(!is_uploaded_file($file))
{
$flag = move_uploaded_file($file_tmp, $path);
if($flag == true)
{
echo "Moved Success";
}
else
{
echo "Some problem";
}
}
else
{
echo "Already Uploaded";
}
}
else
{
echo "Not audio file";
}
}
else if($size > 10000000)
{
echo "Size exceeded";
}
else if($size == null)
{
echo "Please select a file";
}
else
{
echo "Error".$file_err;
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<form action="basic.php" method="post" enctype="multipart/form-data">
<input type="file" name="files"/>
<input type="submit" value="upload" name="submit"/>
</form>
</body>
</html>
答案 0 :(得分:0)
如果您要上传mp3文件,则$ _FILES的类型必须为
&& $_FILES["file"]["type"] == "audio/mp3"
不是
&& $_FILES['files']['type'] == "audio/mpeg"