thinkphp多图片上传问题

WBOY
Release: 2016-06-23 13:59:19
Original
961 people have browsed it

<div class="add">    <form action="" method="post" enctype="multipart/form-data">        <input type="text" name="ceshi1" class="xinxi" value="您的姓名1" onfocus="if (value =='您的姓名1'){value =''}"/>        <input type="text" name="ceshi2" class="xinxi" value="您的姓名2" onfocus="if (value =='您的姓名2'){value =''}"/>        <input type="text" name="ceshi3" class="xinxi" value="您的姓名3" onfocus="if (value =='您的姓名3'){value =''}"/>        <input type="text" name="ceshi4" class="xinxi" value="您的姓名4" onfocus="if (value =='您的姓名4'){value =''}"/>        <input type="text" name="ceshi5" class="xinxi" value="您的姓名5" onfocus="if (value =='您的姓名5'){value =''}"/>        <input type='file'  name='ceshie[]'>        <input type='file'  name='ceshie[]'>        <input type="submit" value="Submit"/>    </form></div>
Copy after login




       $upload = new \Think\Upload(); // 实例化上传类            $upload->maxSize = 3145728; // 设置附件上传大小            $upload->exts = array('jpg', 'gif', 'png', 'jpeg'); // 设置附件上传类型            $upload->savePath ='1/'; // 设置附件上传目录            // 上传文件            $info = $upload->upload();            trace($info,"所有上传的文件数组");            if (!$info) { // 上传错误提示错误信息                $this->error($upload->getError());            } else { // 上传成功                $this->success('上传成功!', U('index/index1'));                foreach($info as $file){                    $urls=__ROOT__.'/Uploads/'.$file['savepath'].$file['savename'];                    array_push($urlss,$urls);                }            }
Copy after login


我明明传了2个文件 为什么        trace($info,"所有上传的文件数组"); 只获取了1个数组。。。求大神帮忙


回复讨论(解决方案)

楼主多文件上传
建议你这样做:给附件单独建立一个表存放,没传成功一个附件往这个表写一条记录,且js中增加一个附件记录,当上传多个附件的时候就相当于选择了多次。这样做出错的概率会小很多。

print_r($info); 看看
$info 只会保存上传成功的文件信息

确定一下$info = $upload->upload();是否支持多文件上传。。。

 
 

试试

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template