时间:2021-07-01 10:21:17 帮助过:19人阅读
?
0&&$file[size]>$maxsize)return "size"; if(!is_dir($dir))mkdir($dir); list($second,$unix)=explode(" ",microtime()); $name=$unix.($second*100000000).strstr($file[name],".");//根据时间为上传的文件重新命名,精确到微秒 move_uploaded_file($file[tmp_name], $dir.$name); return $name; } } /* * $field 指定form表单中的input字段名最后以[]结尾,例如:image[] */ function uploadfile_table($field,$type,$dir,$maxsize=0){ if($_FILES[$field]!=null){ $file=$_FILES[$field]; $count=count($file[name]); $arr=array(); if(!is_dir($dir))mkdir($dir); for($i=0;$i<$count;$i++){ if($file[error][$i]==1){ $arr[$i]="error"; continue; } if($type!=strstr($file[type][$i],"/",true)){ $arr[$i]="type"; continue; } if($maxsize>0&&$file[size][$i]>$maxsize){ $arr[$i]="size"; continue; } list($second,$unix)=explode(" ",microtime()); $name=$unix.($second*100000000).strstr($file[name][$i],"."); move_uploaded_file($file[tmp_name][$i], $dir.$name); $arr[$i]=$name; } return $arr; } } echo ""; //print_r(uploadfile("upimage", "image", $_SERVER['DOCUMENT_ROOT']."/picture/",5120));//上传单个文件 print_r(uploadfile_table("upimage", "image", $_SERVER['DOCUMENT_ROOT']."/picture/"));//上传多个文件 echo "" ?>
?
?上传多个文件
?