网站制作学习网PHP→正文:Thinkphp 多文件上传
字体:

Thinkphp 多文件上传

PHP 2011/11/14 17:47:06  点击:不统计

<网f站o学a习s制p作.cn>

Thinkphp 多文件上传修改,很简单。

首先将上传的图片的input进行数组形式的命名,如下
<input name="image[]" id="image" type="file" class="file huge" />
<input name="image[]" id="image" type="file" class="file huge" />
<input name="image[]" id="image" type="file" class="file huge" />
可以更多个图片,只要名称为image[]就行。
然后修改上传后的代码
if (!$upload->upload()) {
//捕获上传异常
$this->error($upload->getErrorMsg());
}else{
 $uploadList = $upload->getUploadFileInfo();//这里是获取的所有的图片信息   
 $file=$_FILES["image"]["name"];         
 for($i=0;$i<count($file);$i++){
 //生成的文件名分别是 $uploadList[$i]['savename'];             
  import("@.ORG.Image");
   //给m_缩略图添加水印, Image::water('原文件名','水印图片地址')
 Image::water($uploadList[$i]['savepath'].'m_'.$uploadList[$i]['savename'], '../Public/Images/logo2.png');
   }
}
完毕, 修改的地方只是多了一个for循环是逐个输出上传后的文件信息。


http://%77%77%77%2E%66网站制作%6F学习网%72%61%73%70%2E%63%6E

·上一篇:php生成excel文件 >>    ·下一篇:win7安装配置memcache+php >>
推荐文章
最新文章