ThinkPHP上次和下载封装

枕上从妨一夜睡,灯前读尽十年诗。这篇文章主要讲述ThinkPHP上次和下载封装相关的知识,希望能为你提供帮助。
html

< a rel="nofollow" href="https://www.songbingjia.com/android/$v.url" onclick="count($v.id)"> < img src="https://www.songbingjia.com/android/__PUBLIC__/FrontStyle/img/img_project/down.png" class="downimg2"> < /a>

< script type="text/javascript"> function count(obj) $.ajax( url:":U(/Files/count)", type:post, dataType: json, data:"id":obj ); < /script>

php【ThinkPHP上次和下载封装】Files/count的的函数中,后台获取到了前台的函数进行对数据库操作
public function count() $map["id"]=$_POST["id"]; $res=M("Files")-> where($map)-> setInc(pv,1);

html
< form action=":U(/News/save_blog)" method="post" id="myform" name="myform" enctype="multipart/form-data">

< td> < input type="file" name="file" style="width: 80%; height: 30px" /> < i class="msg require-red"> < /i> < /td>

public function save_blog()if (is_uploaded_file ( $_FILES [file] [tmp_name] )) $icon = $_FILES [file]; $iconPath = "Public/images/news/" . time () . $icon [name]; $data ["file"] ="/$iconPath"; $icon [name] = iconv(utf-8,gb2312,$icon [name]); $iconPath = "Public/images/news/" .time (). $icon [name]; move_uploaded_file ( $icon [tmp_name], $iconPath );

$icon [name] = iconv(utf-8,gb2312,$icon [name]);
是为了解决文件上传的时候中文乱码的情况
然后然后才能给予正确的移动路径,然后再进行
$iconPath = "Public/images/news/" .time (). $icon [name]; move_uploaded_file ( $icon [tmp_name], $iconPath );

$id=I(post.id); if($id> 0)$map[id]=$id; $data[add_time]=time(); $res=$this-> blog_model-> where($map)-> save($data); if($res) $this-> success("编辑成功",U(/News/index)); else $this-> success("编辑失败",U(/News/index)); else$res=$this-> blog_model-> add($data); if($res) $this-> success("添加成功",U(/News/index)); else $this-> success("添加失败",U(/News/index));


    推荐阅读