我需要将图片上传到页面/服务器,但每次我需要上传到网站时都会看到它,并且无论我做什么,都会一直说“错误”。它不会上传图片并删除旧的个人资料图片
<?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>
问题是:它只出现错误而没有别的。 怎么可能不打扰上传和删除旧的问题图片。
我根本没有看到错误!