Home >php教程 >php手册 >一次上传多个文件

一次上传多个文件

WBOY
WBOYOriginal
2016-06-13 09:52:57851browse




一次上传多个文件

[img]http://file:///D:/1.jpg[/img]
请问下这种类型的能随意增加减少上传图片的input要怎么实现,有人能帮我写个这样的代码么?且并接收的页面要能成功的接收到这边传过去的图片


最佳答案[url=http://www.111cn.cn/bbs/space.php?username=E网逍遥]链接标记E网逍遥[/url]
[url=http://www.111cn.cn/bbs/space.php?uid=58710]链接标记[img]http://www.111cn.cn/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 .="

  • $val 上载成功(".$_FILES['fname']['size'][$key]."字节)
  • ";

    $file_num ++;

    }else{

    $stat = "error";

    $message .="
  • $val 上载失败
  • ";

    }

    }

    }

    ?>







    动态多文件上传











































    Statement:
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
    Previous article:jquery的问题Next article:求助Apache无法安装