-1 php if-statement syntax-error
我正在尝试使用index.html来使用此脚本:
<form action="upload.php" method="post"
enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="file" id="file" />
<br />
<input type="submit" name="submit" value="Upload" />
</form>
Run Code Online (Sandbox Code Playgroud)
要通过连接到这个(称为upload.php)上传mp3文件:
<?php
if ((($_FILES["file"]["type"] == "audio/mp3") //File type
|| ($_FILES["file"]["type"] == "audio/mp3"))
&& ($_FILES["file"]["size"] < 21000000) //20MB File Size
{
if ($_FILES["file"]["error"] > 0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
}
else
{
echo "";//another echo to display after upload is complete
if (file_exists("mp3/" . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],
"mp3/" . $_FILES["file"]["name"]);
//Below shows the link for the mp3
echo "http://www.Domain here". "mp3/" . $_FILES //Only change domain here leave directory
["file"]["name"] ."";
}
}
}
else
{
echo "Extension not allowed"; //Error message here if it's to big or wrong extension
}
?>
Run Code Online (Sandbox Code Playgroud)
但我总是得到这个错误:
Parse error: syntax error, unexpected '{' in /var/www/xxxx/test/upload.php on line 5
Run Code Online (Sandbox Code Playgroud)
我一直在尝试通过在Stack Overflow上查看主题后添加/删除}来找到问题,但是失败了.谁能告诉我什么是错的?提前致谢!
你错过了一个结束 )
if ((($_FILES["file"]["type"] == "audio/mp3") //File type
|| ($_FILES["file"]["type"] == "audio/mp3"))
&& ($_FILES["file"]["size"] < 21000000)) //20MB File Size
{
Run Code Online (Sandbox Code Playgroud)
真的很明显.