本文整理匯總了PHP中UploadFile::getNewName方法的典型用法代碼示例。如果您正苦於以下問題:PHP UploadFile::getNewName方法的具體用法?PHP UploadFile::getNewName怎麽用?PHP UploadFile::getNewName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類UploadFile
的用法示例。
在下文中一共展示了UploadFile::getNewName方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: show
private function show()
{
$user = new userModel();
$upload = new UploadFile("pic", "public/uploads/member");
if (isset($_POST['send'])) {
$user->id = $_POST['id'];
$user->email = $_POST['email'];
if ($_POST['pwd'] == $_POST['newpwd']) {
$user->pwd = $_POST['newpwd'];
} else {
$user->pwd = md5($_POST['newpwd']);
}
if (is_uploaded_file($_FILES['pic']['tmp_name'])) {
if ($upload->upload("pic")) {
$user->icon = $upload->getNewName();
}
} else {
$user->icon = $_POST['newpic'];
//echo "沒有上傳".$_POST['newpic'];
}
//Tools::dump($_POST);
if ($user->updateUser()) {
//echo "ok";
Tools::Redirect("會員資料修改成功", $_SERVER['HTTP_REFERER']);
} else {
if ($user->updateUser() == 0) {
Tools::Redirect("會員資料沒有修改", $_SERVER['HTTP_REFERER']);
//echo "not changed";
} else {
Tools::Redirect("會員資料修改失敗", $_SERVER['HTTP_REFERER'], 2);
}
}
}
$comment = new commentModel();
$article = new articleModel();
$product = new productModel();
$ask = new askModel();
$quiz = new quizModel();
if ($_GET['id']) {
$user->id = $_GET['id'];
$oneUser = $user->getOneUserByID();
$this->smarty->assign("oneUser", $oneUser);
/////////////////////////////////
$comment->uid = $_GET['id'];
$allComments = $comment->getAllCommentsByUID();
foreach ($allComments as $key => $value) {
$article->id = $value->aid;
$oneArticle = $article->getOneArticle();
$value->title = $oneArticle->title;
}
$product->uid = $_GET['id'];
$allOrders = $product->getAllOrdersByUID();
foreach ($allOrders as $value) {
$pids = explode(",", $value->pid);
$str = null;
foreach ($pids as $v) {
$product->id = $v;
//Tools::dump($v);
$oneProduct = $product->getOneProduct();
//Tools::dump($oneProduct);
$str .= $oneProduct->name . ",";
}
$str = rtrim($str, ",");
//Tools::dump($str);
$value->pid = $str;
switch ($value->payed) {
case 0:
$value->payed = "<span style='color:red;'>[未付]</span>";
break;
case 1:
$value->payed = "<span style='color:green;'>[已付]</span>";
}
switch ($value->sent) {
case 0:
$value->sent = "<span style='color:red;'>[未發貨]</span>";
break;
case 1:
$value->sent = "<span style='color:green;'>[已發貨]</span>";
}
}
$ask->aid = $_GET['id'];
$allAsks = $ask->getAllAskByAID();
$this->smarty->assign("allAsks", $allAsks);
$this->smarty->assign("allOrders", $allOrders);
$this->smarty->assign("allComments", $allComments);
$quiz->uid = $_GET["id"];
$allScores = $quiz->getAllScoresByUID();
$course = new courseModel();
foreach ($allScores as $key => $value) {
$course->id = $value->cid;
$oneCourse = $course->getOneCourse();
$value->cid = $oneCourse->name;
}
$this->smarty->assign("allScores", $allScores);
}
$this->smarty->assign("show", true);
}
示例2: add
public function add()
{
if (isset($_POST['send'])) {
if (is_uploaded_file($_FILES['pix']['tmp_name'])) {
$upload = new UploadFile("pix", "public/uploads/product/");
if ($upload->upload("pix")) {
$pix = $upload->getNewName();
} else {
Tools::getBack($upload->getErrorMsg());
}
} else {
$pix = "product.gif";
}
$this->model->name = $_POST['name'];
$this->model->price = $_POST['price'];
$this->model->inventory = $_POST['inventory'];
$this->model->pix = $pix;
$this->model->description = $_POST['description'];
if ($this->model->addProduct()) {
Tools::Redirect("添加商品成功", "?a=product&m=adminShow");
} else {
Tools::getBack("添加商品失敗");
}
}
$this->smarty->assign("add", true);
$this->smarty->display("admin/product.html");
}
示例3: add
private function add()
{
if (isset($_POST['send'])) {
//Tools::dump($_POST);
//Tools::dump($_FILES);
if (is_uploaded_file($_FILES['thumbnail']['tmp_name'])) {
$this->model->title = $_POST['title'];
$this->model->link = $_POST['link'];
$this->model->description = $_POST['description'];
$this->model->type = $_POST['type'];
$upload = new UploadFile("thumbnail", "public/uploads/ad/");
if ($upload->upload("thumbnail")) {
$this->model->thumbnail = $upload->getNewName();
if ($this->model->addAd()) {
Tools::Redirect("添加廣告成功", "index.php?a=ad&action=show", 1, 1);
} else {
Tools::Redirect("添加廣告失敗", "index.php?a=ad&action=add", 2, 1);
}
}
} else {
Tools::Redirect("必須要選擇上傳的圖片", $_SERVER['HTTP_REFERER'], 2);
}
$upload = new UploadFile("thumbnail");
$upload->upload("thumbnail");
}
$this->smarty->assign("add", true);
}
示例4: update
private function update()
{
if (isset($_POST['send'])) {
//Tools::dump($_POST);
//Tools::dump($_FILES);
$this->model->id = $_POST['id'];
$this->model->email = $_POST['email'];
if ($_POST['pwd'] != $_POST['pwd2']) {
$this->model->pwd = md5($_POST['pwd']);
} else {
$this->model->pwd = $_POST['pwd'];
}
$file = null;
if (is_uploaded_file($_FILES['icon']['tmp_name'])) {
$upload = new UploadFile("icon", 'public/uploads/member/');
if ($upload->upload("icon")) {
$file = $upload->getNewName();
}
} else {
$file = $_POST['icon2'];
}
$this->model->icon = $file;
if ($this->model->updateUser()) {
Tools::Redirect("修改成功", "?a=user&action=member&id=" . $_POST['id']);
} elseif ($this->model->updateUser() == 0) {
Tools::Redirect("沒有修改", "?a=user&action=member&id=" . $_POST['id']);
} else {
Tools::Redirect("修改失敗", $_SERVER['HTTP_REFERER']);
}
}
if (isset($_GET['id'])) {
$this->model->id = $_GET['id'];
$oneUser = $this->model->getOneUserByID();
//Tools::dump($oneUser);
$this->smarty->assign("oneUser", $oneUser);
}
$this->smarty->assign("update", true);
$this->smarty->display('home/member.html');
exit;
}
示例5: add
private function add()
{
if (isset($_POST['send'])) {
if (is_uploaded_file($_FILES['pic']['tmp_name'])) {
$upload = new UploadFile("pic", "public/uploads/download");
$upload->setAllowType(array('zip'));
if ($upload->upload("pic")) {
$this->model->name = $upload->getNewName();
}
} else {
$this->model->url = $_POST["url"];
}
$this->model->description = $_POST["description"];
$this->model->tid = $_POST["tid"];
$this->model->title = $_POST["title"];
if ($this->model->addDownload()) {
Tools::Redirect("添加上傳內容成功", "?a=download&action=show");
} else {
Tools::Redirect("添加上傳內容失敗", $_SERVER['HTTP_REFERER'], 2);
}
}
$this->topic();
$this->smarty->assign("add", true);
}
示例6: add
private function add()
{
//Tools::dump($_POST);
//exit();
//Tools::dump($_FILES);
$thumbnail = null;
$this->nav();
$this->mall();
if (isset($_POST['send'])) {
if (empty($_POST['nid'])) {
Tools::getBack("必須選擇一個欄目");
}
if (is_uploaded_file($_FILES['thumbnail']['tmp_name'])) {
$upload = new UploadFile("thumbnail", "public/uploads/article/");
if ($upload->upload("thumbnail")) {
$thumbnail = $upload->getNewName();
} else {
Tools::getBack($upload->getErrorMsg());
}
} else {
$thumbnail = "default.jpg";
}
//echo $thumbnail;
$this->model->title = $_POST['title'];
$this->model->lead = $_POST['lead'];
$this->model->content = $_POST['content'];
$this->model->author = $_POST['author'];
$this->model->tag = $_POST['tag'];
$this->model->thumbnail = $thumbnail;
$this->model->nid = $_POST['nid'];
$this->model->cid = $_POST['cid'];
$this->model->source = $_POST['source'];
$this->model->pageview = 1;
//echo implode(",", $_POST['attr']);
$this->model->attr = implode(",", $_POST['attr']);
if ($this->model->addArticle()) {
Tools::Redirect("添加文章成功", "?a=article&action=show");
} else {
Tools::getBack("添加文章失敗");
}
}
$this->smarty->assign("add", true);
}