簡體   English   中英

語法錯誤,我的代碼上的意外文件結束

[英]syntax error, unexpected end of file on my code

對不起,我不知道我的代碼中的錯誤在哪里,它必須是一個簡單的{
這是一個將imgs上傳到數據庫的簡單表單,所以如果有人想讓它隨意使用它。

<html>
<body> 
    <form method="post" action="">
        <p>Selecionar imagem:</p>
        <input type="file" name="fileToUpload" id="fileToUpload">
        <p>descricao:</p>
        <input name="descricao" type="text">
        <p>categoria:</p>
        <input name="categoria" type="text">
        <input type="submit" value="Submit" name="submit">
    </form>
</body>
</html>

<?php
    $con = mysql_connect("localhost", "root", "", "galeria");
    if (!$con)
    {
        die('Could not connect: '.mysql_error());
    }

    mysql_select_db("galeria", $con);
    if (isset($_POST["submit"]))
    {
        $sql = "INSERT INTO gallery (id,lowsrc,fullsrc,description,category)
    VALUES
    ('','$_POST[fileToUpload]','$_POST[fileToUpload]','$_POST[descricao]','$_POST[categoria]')";

        if (!mysql_query($sql, $con))
        {
            die('ERRO: '.mysql_error());
        }
        echo "adicionado";
        if (array_key_exists("submit", $_POST))
        {
            $target_dir = "full/";
            $target_file = $target_dir.basename($_FILES["fileToUpload"]["name"]);
            $uploadOk = 1;
            $imageFileType = pathinfo($target_file, PATHINFO_EXTENSION);

            if (isset($_POST["submit"]))
            {
                $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
                if ($check !== false)
                {
                    echo "OK - ".$check["mime"].".";
                    $uploadOk = 1;
                }
                else
                {
                    echo "Não é uma imagem";
                    $uploadOk = 0;
                }
            }
            // Check if file already exists
            if (file_exists($target_file))
            {
                echo "Ficheiro ja existe!";
                $uploadOk = 0;
            }
            // Check file size
            if ($_FILES["fileToUpload"]["size"] > 500000)
            {
                echo "Ficheiro muito grande!";
                $uploadOk = 0;
            }
            // Allow certain file formats
            if ($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif")
            {
                echo "Apenas JPG, JPEG, PNG e GIF são permitidos";
                $uploadOk = 0;
            }
            // Check if $uploadOk is set to 0 by an error
            if ($uploadOk == 0)
            {
                echo "ERRO";
                // if everything is ok, try to upload file
            }
            else
            {
                if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file))
                {
                    echo "Upload Feito";
                }
                else
                {
                    echo "ERRO";
                }
            }
        }
?>

我已經解析了你的代碼,它說你需要在最后一個結束標記之前添加一個額外的括號}

最后添加結束花括號}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM