upload.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="http://c.mfniu.com/js/lib/jquery.js"></script>
<title>多图片上传实例1</title>
</head>

<body>
<div class="upload_btn" onclick="fileElem.click()">选择上传图片</div>
<form action="upload.php" method="post" enctype="multipart/form-data">
<div id="filebox">
<input class="inputimg" type="file" id="fileElem0" name="img[]" multiple="multiple" accept="image/*" onchange="handleFiles(this)">
</div>
<div class="showimgdiv" id="fileList" ></div>
<br><input class="inputimg" type="submit" value="提交">
</form>
<script>
window.URL = window.URL || window.webkitURL;
var fileList = document.getElementById("fileList");
var num = 0;

function handleFiles(obj) {
var sname = 'fileElem'+num;
num++;
var xname ='fileElem'+num;

$('#'+sname).hide();
$('#filebox').append('<input class="inputimg" type="file" id="'+xname+'" name="img[]" multiple="multiple" accept="image/*" onchange="handleFiles(this)">');

if(fileList.childNodes.length>=6){
alert("最多只能上传6张图片哦!");
return false;
}

/* 方法2
if(num>5){
alert("最多只能上传6张图片哦!");
return false;
}
*/

var files = obj.files,
img = new Image();

var div = document.createElement("div");//创建一个DIV
div.style.width = "100px";
div.style.height = "100px";
div.style.border = "1px solid #111";
div.style.margin = "2px";
div.style.float = "left";
div.style.boxShadow = " 2px 2px 4px #aaa";

img.src = window.URL.createObjectURL(files[0]);
img.style.width = "100px";
img.style.height = "100px";
img.name="img[]";
img.onload = function(e) {
window.URL.revokeObjectURL(this.src);
}

div.appendChild(img);
fileList.appendChild(div);
}
</script>
</body>
</html>

upload.php

<?php

var_dump($_FILES);

PHP 多图片上传实例demo的更多相关文章

  1. PHP多图片上传实例demo

    upload.html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:/ ...

  2. Thinkphp整合阿里云OSS图片上传实例

    Thinkphp3.2整合阿里云OSS图片上传实例,图片上传至OSS可减少服务器压力,节省宽带,安全又稳定,阿里云OSS对于做负载均衡非常方便,不用传到各个服务器了 首先引入阿里云OSS类库 < ...

  3. PHP结合zyupload多功能图片上传实例

    PHP结合zyupload多功能图片上传实例,支持拖拽和裁剪.可以自定义高度和宽度,类型,远程上传地址等. zyupload上传基本配置 $("#zyupload").zyUplo ...

  4. layui加tp5图片上传实例

    <div class="layui-fluid"> <div class="layui-row"> <form class=&qu ...

  5. webuploader项目中多图片上传实例

    <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content ...

  6. asp.net图片上传实例

    网站后台都需要有上传图片的功能,下面的例子就是实现有关图片上传. 缺点:图片上传到本服务器上,不适合大量图片上传. 第一.图片上传,代码如下: xxx.aspx 复制代码代码如下: <td cl ...

  7. Thinkphp框架图片上传实例

     https://www.cnblogs.com/wupeiky/p/5802191.html    [原文转载自:https://www.cnblogs.com/guoyachao/p/628286 ...

  8. struts2多图片上传实例【转】

    原文地址:http://blog.csdn.net/java_cxrs/article/details/6004144 描述: 通过struts2实现多图片上传. 我使用的版本是2.2.1,使用的包有 ...

  9. uploadify多图片上传实例

    upload.php <html> <head> <meta http-equiv="Content-Type" content="text ...

随机推荐

  1. PIE SDK组件式开发综合运用示例

    1. 功能概述 关于PIE SDK的功能开发,在我们的博客上已经分门别类的进行了展示,点击PIESat博客就可以访问,为了初学者入门,本章节将对从PIE SDK组件式二次开发如何搭建界面.如何综合开发 ...

  2. GCC 7.3.0版本编译http-parser-2.1问题

    http-paser是一个用c编写的http消息解析器,地址:https://github.com/nodejs/http-parser,目前版本2.9 今天用gcc 7.3.0编译其2.1版本时,编 ...

  3. mysql 5.7 的 /etc/my.cnf

    mysql的my.cnf文件纯净版的.随意享用. # Example MySQL config file for medium systems. # # This is for a system wi ...

  4. ubuntu 16.04 屏幕截图

    shift+prtsc   快捷键截取指定区域的图片 类似qq截图

  5. Failed to start NodeManager caused by "/var/lib/hadoop-yarn/yarn-nm-recovery/yarn-nm-state/LOCK: Permission denied"

      Hadoop 安装步骤: 0. 安装前准备(节点机器,环境设置,yum源设置) 1. 配置并安装Cloudera-Manager 2. 启动 CM 服务 3. 安装CDH,并配置集群 4. 启动 ...

  6. PL/SQL 游标

    本随笔不是原创,只是学习笔记,用于加深记忆,原创地址PL/SQL --> 游标 一.游标的相关概念和特性 1.定义: 映射到结果集中的某一行的特定位置,类似与C语言中的指针.即通过游标方式定位到 ...

  7. PHP面向对象的基本原则

    对象内部是高内聚的 ——对象只负责一项特定的功能(职能可大可小) ——所有对象相关的内容都封装到对象内部 高内聚就是该有的都有,用的时候不会缺胳膊少腿! 对象对外是低耦合的 ——外部世界可以看到对象的 ...

  8. how to run windows programs on a MAC?

    How to run windows programs on a MAC? We could use wine or Wine Bottler which is based on wine and p ...

  9. 如何正确且高效地中文汉化Spyder 2 或 Spyder3(图文详解)(博主推荐)

    不多说,直接上干货!   汉化下载和教程页面 : https://github.com/kingmo888/Spyder_Simplified_Chinese 汉化文件最新版直接下载 : https: ...

  10. unity小地图上的动态图标

    unity制作小地图简单,用rawImage 再来个摄像机就行 但是现在一个需求就是地图上一些东西要加上图标,图标会随着地图物体的移动而移动 然后去网上下载了个小地图插件  UGUI MiniMap( ...