public static function upFile($r,$p=‘../images/link/‘,$type=‘gif,jpg,png‘,$named=0){ $newnames = null; //var_dump($r); foreach($r as $v){ //var_dump($v[‘name‘]); $name = $v[‘name‘]; $name1 = explode(‘.‘,$name); $ext = $name1[count($name1)-1]; var_dump($ext); if(in_array($ext,explode(‘,‘,$type))){ $n = $named==0 ? date(‘YmdHis‘).‘.‘.$ext : $named; var_dump($n); move_uploaded_file($v[‘tmp_name‘],$p.$n); $newnames[] = $n; } } return $newnames; }
html 文件
<tr> <td>图片:</td> <td><input type="file" name="img_url" value="<?php echo $article->img_url; ?>"/></td>
</tr>
原文地址:http://www.cnblogs.com/xiaoxiao2014/p/3850235.html