在图像上传中取消链接功能错误

时间:2013-11-27 15:36:23

标签: php image unlink

我使用此脚本上传特定产品的图片,但是完成后,我再次使用相似的图片上传,更新其中的信息,但不显示相同的图像,但是当我更改它呈现的图像名称时。 ....不知道如何处理取消链接功能???????请帮忙吗?

<?php
$allowedExts = array("gif", "jpeg", "jpg", "png");
$temp        = explode(".", $_FILES["file"]["name"]);
$extension   = end($temp);

if ((($_FILES["file"]["type"] == "image/gif")
        || ($_FILES["file"]["type"] == "image/jpeg")
        || ($_FILES["file"]["type"] == "image/jpg")
        || ($_FILES["file"]["type"] == "image/pjpeg")
        || ($_FILES["file"]["type"] == "image/x-png")
        || ($_FILES["file"]["type"] == "image/png"))
    && ($_FILES["file"]["size"] < 20000000000000)
    && in_array($extension, $allowedExts)
) {

    if ($_FILES["file"]["error"] > 0) {

        echo "Return Code: " . $_FILES["file"]["error"] . "<br>";

    } else {

        if (file_exists("../upload/" . $_FILES["file"]["name"])) {
            echo $_FILES["file"]["name"] . " already exists. ";
        } else {

            move_uploaded_file($_FILES["file"]["tmp_name"],
                "../upload/" . $_FILES["file"]["name"]);
            $image = $_FILES["file"]["name"];
            unlink($image);
        }
    }
} else {
    echo "Invalid file";
}
?>

0 个答案:

没有答案
相关问题