0

It is such that I need upload a picture to the page / server but every time that I need to upload to the site will see it and say "error here" all the time no matter what I do!. it will not upload picture and delete the old profile picture

<?php
        if(isset($_POST["uploadIMGIndhold"]))
        {
        ?>
        <div style="background:red; padding:5px 3px; color:#fff;" id="top_boxxen_indhold_bruger">
        <?php
            if($_POST["file"] != "")
            {
                if ($stmt = $this->mysqli->prepare('SELECT `img` FROM `bruger` WHERE `id` = ?')) { 
            $stmt->bind_param('i', $id);
            $id = $_SESSION["id"];
            $stmt->execute();
            $stmt->bind_result($img);

            while ($stmt->fetch()) {
                unlink("indhold/profil/" . $img . "");
                unlink("indhold/profil/index/" . $img . "");
            }
            $stmt->close();
        } else {
            echo 'Der opstod en fejl i erklæringen: ' . $this->mysqli->error;
        }


        $pb = null;

        include "indhold/inc/billede/class.upload.php";
        $handle = new Upload($_FILES["file"]);

        if($handle->uploaded)
        {
            $handle->image_resize = true;
            $handle->image_ratio_crop = true;
            $handle->image_y = 75;
            $handle->image_x = 75;
            $handle->Process("indhold/profil");

            $handle->image_resize = true;
            $handle->image_ratio_y = true;
            $handle->image_x = 320;
            $handle->Process("indhold/profil/index");

            $pb = $handle->file_dst_name;
        }

        if ($stmt = $this->mysqli->prepare('UPDATE `bruger` SET `img`=? WHERE `id`=?')) { 
            $stmt->bind_param('ss', $img, $id);
            $img = $pb; 
            $id = $_SESSION["id"];
            $stmt->execute();
                echo "Godkendt";
            $stmt->close();

        } else {
            /* Der er opstÃÂ¥et en fejl */
            echo 'Der opstod en fejl i erklæringen: ' . $this->mysqli->error;
        }   
            }
            else
            {
                echo "<p class=\"luk_ned_igen\">Error here</p>";
            }
        ?>
        </div>
        <?php
        }
    ?>

        <h5>Upload Profilbillede</h5>
        <form action="#" enctype="multipart/form-data" method="post">
            <table>
                <tr>
                    <td>Profilbillede</td>
                    <td><input type="file" name="file"></td>
                </tr>
                <tr>
                    <td><input type="submit" name="uploadIMGIndhold" value="Upload billedet" class="new upload_boxxen"></td>
                    <td></td>
                </tr>
            </table>
        </form>

the problem is: it only appears with error and nothing else. How can it be that it does not bother upload and delete the old problem picture.

I do not see errors at all!

4

0 回答 0