html tag causing unexpected end of file in .php file

When I open the file using wampserver on my browser it says: "Parse error: syntax error, unexpected end of file in C:wampwwwTestsFileUploadPractiseForm.php on line 53."

I am using php scripts inside the body of the file.

Can't figure out what is the problem. Here is the code:

<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/69798.html

上一篇: 语法错误,意外的文件结束

下一篇: html标记导致.php文件中意外的文件结尾