Ejemplo n.º 1
0
    $iname = trim($_POST["iname"]);
    $href = trim($_POST["href"]);
    $root = $params["root"];
    $rank = trim($_POST["rank"]);
    if (empty($rank)) {
        $rank = 1;
    }
    $old_name = $_FILES["file"]["name"];
    $extension = explode(".", $old_name)[1];
    $imageName = uniqid() . "." . $extension;
    $url = $root . "img/" . $imageName;
    $final_path = dirname(dirname(__FILE__)) . "/web/img/" . $imageName;
    move_uploaded_file($_FILES["file"]["tmp_name"], $final_path);
    $hi = new HomeImage();
    $hi->setIname($iname);
    $hi->setUrl($url);
    $hi->setHref($href);
    $hi->setRank($rank);
    $hi->save();
    header("location:homeImagesController.php");
    exit;
}
if ($action === "edit") {
    $id = $_GET["id"];
    $hi_update = new HomeImage();
    $hi_update->setId($id);
    $hi_update->loadById();
    $isEdit = true;
}
if ($action == "modify") {
    // 提交更改