PHP 多图片上传实例demo
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的更多相关文章
- PHP多图片上传实例demo
upload.html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:/ ...
- Thinkphp整合阿里云OSS图片上传实例
Thinkphp3.2整合阿里云OSS图片上传实例,图片上传至OSS可减少服务器压力,节省宽带,安全又稳定,阿里云OSS对于做负载均衡非常方便,不用传到各个服务器了 首先引入阿里云OSS类库 < ...
- PHP结合zyupload多功能图片上传实例
PHP结合zyupload多功能图片上传实例,支持拖拽和裁剪.可以自定义高度和宽度,类型,远程上传地址等. zyupload上传基本配置 $("#zyupload").zyUplo ...
- layui加tp5图片上传实例
<div class="layui-fluid"> <div class="layui-row"> <form class=&qu ...
- webuploader项目中多图片上传实例
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content ...
- asp.net图片上传实例
网站后台都需要有上传图片的功能,下面的例子就是实现有关图片上传. 缺点:图片上传到本服务器上,不适合大量图片上传. 第一.图片上传,代码如下: xxx.aspx 复制代码代码如下: <td cl ...
- Thinkphp框架图片上传实例
https://www.cnblogs.com/wupeiky/p/5802191.html [原文转载自:https://www.cnblogs.com/guoyachao/p/628286 ...
- struts2多图片上传实例【转】
原文地址:http://blog.csdn.net/java_cxrs/article/details/6004144 描述: 通过struts2实现多图片上传. 我使用的版本是2.2.1,使用的包有 ...
- uploadify多图片上传实例
upload.php <html> <head> <meta http-equiv="Content-Type" content="text ...
随机推荐
- django-获取当前url和ip
1.添加'django.template.context_processors.request', 2.在模板的html中输入 {{ request.path}}{{ request.get_host ...
- J15W-J45W铜截止阀厂家,J15W-J45W铜截止阀价格 - 专题栏目 - 无极资讯网
无极资讯网 首页 最新资讯 最新图集 最新标签 搜索 J15W-J45W铜截止阀 无极资讯网精心为您挑选了(J15W-J45W铜截止阀)信息,其中包含了(J15W-J45W铜截止阀)厂家,(J15 ...
- 【爬虫】-爬取猫眼TOP100
原文崔庆才<python3网络爬虫实战> 本文为自学记录,如有侵权,请联系删除 目标: 熟悉正则表达式,以及爬虫流程 获取猫眼TOP100榜单 1.网站分析 目标站点为http://www ...
- setSelectionRange方法解决光标错位问题
inputElement.setSelectionRange(value.length, value.length);
- 封装element-ui的dialog组件
封装组件: <template> <div class="dialog-container"> <el-dialog title="titl ...
- db2 tsm backup fails with rc–50(1)
2015-01-05-19.21.54.477532+000 E8484227A347 LEVEL: Error PID : 10027058 TID : ...
- JAVA学习2:Eclipse集成Maven
我的环境: Eclipse:eclipse-jee-juno-SR2-win32 Maven:Maven3.0.5 1.Help->Eclipse Marketplace 2.选中要安装的插件, ...
- document.referrer的使用和window.opener 跟 window.parent 的区别
偶尔看到了document.referrer,之前一直有点疑惑与window.opener 和 window.parent之间的区别 首先查了一下w3cSCHOOL, 上面的解释:referrer 属 ...
- CSS的margin属性:详解margin属性
在网上看到的一篇文章,说的比较全面.原文地址:http://www.poluoluo.com/jzxy/201206/167007.html 你真的了解margin吗? 你知道margin有什么特性吗 ...
- 2、编写/修改权限及执行Shell程序的步骤
学习目标编写Shell程序执行Shell程序 正文Shell程序有很多类似C语言和其他程序设计语言的特征,但是又没有程序语言那样复杂.Shell程序是指放在一个文件中的一系列Linux命令和实用程序. ...