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 ...
随机推荐
- Python——Django学习笔记
Django——一个封装好的神奇框架 若本文有任何内容错误,望各位大佬指出批评,并请直接联系作者修改,谢谢!小白学习不易. 一.简要模型 模型类操作数据表: python manage.py shel ...
- Leo-io 的C语言实现简单五子棋游戏观后感
源代码: /************************************************************** ** 文 件 名:wuziqi.cpp ** 功 能:扫 ...
- extjs--combo动态获取数据
<!DOCTYPE html> <html> <head> <link href="https://cdnjs.cloudflare.com/aja ...
- 透视效果shader(边缘光)
思路:渲染两次. 1.第一次渲染:利用Greater进行深度测试,当目标被遮挡时,用一个边缘光的效果显示. 2.第二次渲染:正常渲染. 边缘光的思路:观察方向和顶点法向量夹角越大,边缘光越明显.边缘光 ...
- quickly calc pow(i, n) since i in [1~n]
#include <bits/stdc++.h> using namespace std; #define inf (0x3f3f3f3f) typedef long long int L ...
- C 标准库 - string.h之strpbrk使用
strpbrk Locate characters in string,Returns a pointer to the first occurrence in str1 of any of the ...
- Freemarker list的使用
更新多条记录的操作,这里ids是一个数组 <sqltemplate id = "disableBuildLabourer"> <![CDATA[ UPDATE b ...
- C#泛型List的介绍
一.List<T>描述 1).表示可通过索引访问的对象的强类型列表:提供用于对列表进行搜索.排序和操作的方法.2).是ArrayList类的泛型等效类.3).可以使用一个整数索引访问此集合 ...
- jQuery实现单击和鼠标感应事件。
1.实现单击事件动态交替http://www.cnblogs.com/ahthw/p/4232837.html讲到了toggleClass(),对于单击事件而言,jQuery同样提供了动态交替的tog ...
- java 并发(五)---AbstractQueuedSynchronizer(5)
问题 : ArrayBlockQueue 和 LinkedBlockQueue 的区别 两者的实现又是怎么样的 应用场景 BlockingQueue 概述 blockingQueue 是个接口,从名字 ...