public function createCover($imgFilename, $addon) { $result = array("error" => true); $imgFilename_ext = pathinfo($addon, PATHINFO_EXTENSION); $imgNewName = helper::generateHash(7); $imgOrigin = "origin_c_" . $imgNewName . "." . $imgFilename_ext; $imgNormal = "normal_c_" . $imgNewName . "." . $imgFilename_ext; if ($this->checkImg($imgFilename)) { list($w, $h, $type) = getimagesize($imgFilename); if (rename($imgFilename, "../../" . TEMP_PATH . $imgOrigin)) { $imgFilename = "../../" . TEMP_PATH . $imgOrigin; } if ($type == IMAGETYPE_JPEG) { $this->img_resize($imgFilename, "../../" . TEMP_PATH . $imgNormal, 800, 0); $result['error'] = false; } elseif ($type == IMAGETYPE_PNG) { //PNG $this->img_resize($imgFilename, "../../" . TEMP_PATH . $imgNormal, 800, 0); $result['error'] = false; } else { $result['error'] = true; } } if ($result['error'] === false) { $cdn = new cdn($this->db); $response = array(); $response = $cdn->uploadCover("../../" . TEMP_PATH . $imgNormal); if ($response['error'] === false) { $result['normalCoverUrl'] = $response['fileUrl']; $result['originCoverUrl'] = $response['fileUrl']; } @unlink("../../" . TEMP_PATH . $imgOrigin); @unlink("../../" . TEMP_PATH . $imgNormal); } return $result; }