Home > Backend Development > PHP Tutorial > Upload multiple files at once_PHP tutorial

Upload multiple files at once_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-13 10:51:36
Original
1093 people have browsed it




Upload multiple files at once

[img]http://file:///D:/1.jpg[/img]
Please tell me how to implement this type of input that can add or reduce uploaded images at will. Can anyone help me write such a code? And the receiving page must be able to successfully receive the pictures passed here


The best answer [url=http://www.111cn.cn/bbs/space.php?username=E网Xiaoyao]Link tag EwangXiaoyao[/url]
[url=http://www.111cn.cn/bbs/space.php?uid=58710]Link tag[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."/"; //Upload path

foreach($_FILES['fname']['name'] as $key=>$val){ //Array upload file

$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)) { //Upload file

$message .="

  • $val Upload successful(".$_FILES['fname']['size'][$key]." bytes).
  • ";

    $file_num ++;

    }else{

    $stat = "error";

    $message .="
  • $val Upload failed!
  • ";

    }

    }

    }

    ?>







    Dynamic multiple file upload











































    Copy code



    D8888D reply content------------------------------------------------- ----------


    $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."/"; //Upload path

    foreach($_FILES['fname']['name'] as $key=>$val){ //Array upload file

    $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)) { //Upload file

    $message .="
  • $val Upload successful(".$_FILES['fname']['size'][$key]." bytes).
  • ";

    $file_num ++;

    }else{

    $stat = "error";

    $message .="
  • $val Upload failed!
  • ";

    }

    }

    }

    ?>







    Dynamic multiple file upload

    source:php.cn
    Statement of this Website
    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
    Latest Issues
    Popular Tutorials
    More>
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template