<?php /** * Created by PhpStorm. * User: ajax * Date: 2016/3/17 * Time: 11:03 */ $action = "default"; if (isset($_GET["action"])) { $action = $_GET["action"]; } if ($action == "delete") { $id = $_GET["id"]; HomeImage::deleteById($id); } if ($action == "add") { $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);