TP框架之多文件上传
来源:互联网 发布:java 退出程序 编辑:程序博客网 时间:2024/06/11 22:05
视图层
<center>
<form method="post" action="__URL__/add" enctype="multipart/form-data">
<table border="1">
<tr>
<td>品牌</td>
<td><input type="text" name="g_name"/></td>
</tr>
<tr>
<td>品牌logo</td>
<td><input type="file" name="g_img[]"/></td>
</tr>
<tr>
<td>图片展示</td>
<td>
<input type="file" name="g_img[]"/><br/>
<input type="file" name="g_img[]"/><br/>
<input type="file" name="g_img[]"/><br/>
</td>
</tr>
<tr>
<td>描述</td>
<td><textarea rows="6" cols="12" name="g_desc"></textarea></td>
</tr>
<tr>
<td><input type="submit" value="提交"/></td>
<td><input type="reset" value="重置"/></td>
</tr>
</table>
</form>
</center>
控制器
public function index(){
$this->display('form');
}
//提交验证
function add()
{
//验证图片
$upload = new \Think\Upload();// 实例化上传类
$upload->maxSize = 314572800 ;// 设置附件上传大小
$upload->exts = array('jpg', 'gif', 'png', 'jpeg');// 设置附件上传类型
$upload->savePath = './Public/Uploads/'; // 设置附件上传目录
$upload->rootPath='./';
// 上传文件
$info = $upload->upload();
if(!$info) {
$this->error($upload->getError());
}
//拼凑路径
$path=$info[0]['savepath'].$info[0]['savename']; //品牌logo的路径
$str='';
for($i=1;$i<count($info);$i++)
{
$str.='-'.$info[$i]['savepath'].$info[$i]['savename'];
}
$spath=trim($str);
//print_r($spath);
//把各自的路径放在各自的字段中
$_POST['g_logo']=$path;
$_POST['g_img']=$spath;
//接受表单其他值
$data=I('post.');
$biao=M('biao3');
$bol=$biao->add($data);
if($bol)
{
$this->success('添加成功',U('Goods/show'),2);
}else{
$this->error('添加失败');
}
}
- TP框架之多文件上传
- TP框架之多文件上传(2)
- TP框架 上传类 没有上传的文件
- tp文件上传
- php之多文件上传
- TP上传文件图片总结
- TP上传文件 临时文件夹不存在
- AdobeFlexCookBook之多重文件上传
- 复习struts2之多文件上传
- struts2之多个文件上传
- struts2之多个文件上传
- struts2之多个文件上传
- struts2之多个文件上传
- struts2之多个文件上传
- struts2之多个文件上传
- tp 多文件上传,文件及时预览
- TP上传文件的自定义名称
- TP框架上传图片时报错“非法上传"处理
- Lintcode_16 Permutations II
- The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path
- Lintcode_18 Subsets II
- C# 怎样将DateTime类型进行日期的加减
- java学习总结(16.06.28)包装类和包装类的常用方法
- TP框架之多文件上传
- linux基础学习笔记-7-ssh服务,NFS服务,tftp服务
- 详解移位运算符-二进制中1的个数
- 1016
- [暴搜剪枝] BZOJ 3733 [Pa2013]Iloczyn
- [拆边费用流] BZOJ 1449 [JSOI2009]球队收益
- 矢量字体字形分布图
- 1012. The Best Rank (25)
- activeMQ消息中文乱码解决