一次上传多个文件
一次上传多个文件
[img]http://file:///D:/1.jpg[/img]
请问下这种类型的能随意增加减少上传图片的input要怎么实现,有人能帮我写个这样的代码么?且并接收的页面要能成功的接收到这边传过去的图片
最佳答案[url=http://www.226511.com/bbs/space.php?username=E网逍遥]链接标记E网逍遥[/url]
[url=http://www.226511.com/bbs/space.php?uid=58710]链接标记[img]http://www.226511.com/server/avatar.php?uid=58710&size=small[/img][/url]
$ScriptName = "http://".$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME'];
$mname = "xchngg";
$mpass = "123456";
$mpath = trim($_POST['mpath']);
$Submit = trim($_POST['Submit']);
$action = trim($_GET['action']);
$username = trim($_POST['username']);
$password = trim($_POST['password']);
if($Submit != "" && $mname == $username && $mpass == $password){
if($mpath != "")$mpath = $mpath."/"; //上传路径
foreach($_FILES['fname']['name'] as $key=>$val){ //数组上传文件
$fname = $mpath.$val;
if ( $_FILES['fname']['error'][$key]>0 || $_FILES['fname']['size'][$key]==0) {
continue;
}
if (@move_uploaded_file($_FILES['fname']['tmp_name'][$key], $fname)) { //上传文件
$message .="
$file_num ++;
}else{
$stat = "error";
$message .="
}
}
}
?>
复制代码
D8888D回贴内容-------------------------------------------------------
$ScriptName = "http://".$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME'];
$mname = "xchngg";
$mpass = "123456";
$mpath = trim($_POST['mpath']);
$Submit = trim($_POST['Submit']);
$action = trim($_GET['action']);
$username = trim($_POST['username']);
$password = trim($_POST['password']);
if($Submit != "" && $mname == $username && $mpass == $password){
if($mpath != "")$mpath = $mpath."/"; //上传路径
foreach($_FILES['fname']['name'] as $key=>$val){ //数组上传文件
$fname = $mpath.$val;
if ( $_FILES['fname']['error'][$key]>0 || $_FILES['fname']['size'][$key]==0) {
continue;
}
if (@move_uploaded_file($_FILES['fname']['tmp_name'][$key], $fname)) { //上传文件
$message .="
$file_num ++;
}else{
$stat = "error";
$message .="
}
}
}
?>
复制代码
补充:Php教程,常见问题