本文整理汇总了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);
}