在test.php文件中
<form action="upload.php" method="post" enctype="multipart/form-data">
<p>Pictures:<br />
<input type="file" name="pictures[]" /><br />
<input type="file" name="pictures[]" /><br />
<input type="file" name="pictures[]" /><br />
<input type="submit" name="upload" value="添加" />
</p>
</form>
在upload.php中如下
<?php
$uploadfile;
if($_POST['upload']=='添加'){
$dest_folder = "picture/"; //上传图片保存的路径 图片放在跟你upload.php同级的picture文件夹里
$arr=array(); //定义一个数组存放上传图片的名称方便你以后会用的,如果不用那就不写
$count=0;
if(!file_exists($dest_folder)){
mkdir($dest_folder);
}
foreach ($_FILES["pictures"]["error"] as $key => $error) {
if ($error == UPLOAD_ERR_OK) {
$tmp_name = $_FILES["pictures"]["tmp_name"][$key];
$name = $_FILES["pictures"]["name"][$key];
$uploadfile = $dest_folder.$name;
move_uploaded_file($tmp_name, $uploadfile);
$arr[$count]=$uploadfile;
// $files=substr($uploadfile,3); //如果你到底的图片名称不是你所要的你可以用截取字符得到
echo $uploadfile."<br />";
echo $files."<br />";
echo $arr[$count]."<br />";
$count++;
}
}
}
?>