html标记导致.php文件中意外的文件结尾

当我在浏览器上使用wampserver打开文件时,它说:“解析错误:语法错误,在第53行的C: wamp www Tests FileUploadPractiseForm.php中出现意外的文件结尾。”

我在文件正文中使用了php脚本。

无法弄清楚是什么问题。 代码如下:

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" 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="Submit">

<?php
if (isset($_POST["submit"]))
{
    $name=$_FILES["file"]["name"];
    $tmp_name=$_FILES["file"]["tmp_name"];
    $error=$_FILES["file"]["error"];
    $size=$_FILES["file"]["size"];
    $type=$_FILES["file"]["type"];

    $allowedExts = array("gif", "jpeg", "jpg", "png"); //Specify allowed Extensions
    $temp = explode(".", $name); //Split up file name
    $extension = end($temp); //Assign to last element of array with file-name parts ie extension.

    if ( (($type == "image/gif")||($type == "image/jpeg")||($type == "image/jpeg")||($type == "image/png")||($type == "image/x-png")||($type == "image/pjepg")) && ($size < 1048476) && in_array($extension, $allowedExts) ) //check if its an image, if its less than max size, if its extension is allowed
        {
            if ( $error > 0) 
                {
                    echo "Error: " . $error . "<br>"; //in case there's an upload error
                } 
            else if (isset($name))
                { 
                    if (!empty($name))
                        {
                            $location='upload/';
                            move_uploaded_file($tmp_name, $location.$name);
                            echo "Image Uploaded";  //this if-else section is used to store the file in non-temp location ie "upload" folder
                        }
                }
        }
    else 
        {
            if ($size >= 1048476)
                {
                    echo "Maximum File Size Exceeded";
                }
            else
                {
                    echo "Invalid File Type";
                }
        }
?>

</form>
</body>
</html>

你缺少收盘}为你的第一个if在PHP代码。

链接地址: http://www.djcxy.com/p/69797.html

上一篇: html tag causing unexpected end of file in .php file

下一篇: Error : Parse error: syntax error, unexpected $end