网站地图    收藏   

主页 > php专栏 > php上传下载 >

ajax php多文件上传代码 - php上传下载

来源:自学PHP网    时间:2014-11-28 00:00 作者: 阅读:

[导读] !doctypehtmlpublic-//w3c//dtdxhtml1.0transitional//enhttp://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtdhtmlxmlns=http......

ajax php多文件上传代码

  1. <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"
  2. <html xmlns="http://www.w3.org/1999/xhtml"
  3. <head> 
  4. <meta http-equiv="content-type" content="text/html; charset=utf-8" /> 
  5. <title>ajax php多文件上传代码</title> 
  6. <script> 
  7. (function(){ 
  8.   
  9. var d = document, w = window; 
  10. /** 
  11.  * get element by id 
  12.  */  
  13. function get(element){ 
  14.  if (typeof element == "string"
  15.   element = d.getelementbyid(element); 
  16.  return element; 
  17. /** 
  18.  * attaches event to a dom element 
  19.  */ 
  20. function addevent(el, type, fn){ 
  21.  if (w.addeventlistener){ 
  22.   el.addeventlistener(type, fn, false); 
  23.  } else if (w.attachevent){ 
  24.   var f = function(){ 
  25.     fn.call(el, w.event); 
  26.   };    
  27.   el.attachevent('on' + type, f) 
  28.  } 
  29.  
  30. /** 
  31.  * creates and returns element from html chunk 
  32.  */ 
  33. var toelement = function(){ 
  34.  var div = d.createelement('div'); 
  35.  return function(html){ 
  36.   div.innerhtml = html; 
  37.   var el = div.childnodes[0]; 
  38.   div.removechild(el); 
  39.   return el; 
  40.  } 
  41. }(); 
  42. function hasclass(ele,cls){ 
  43.  return ele.classname.match(new regexp('(s|^)'+cls+'(s|$)')); 
  44. function addclass(ele,cls) { 
  45.  if (!hasclass(ele,cls)) ele.classname += " "+cls; 
  46. function removeclass(ele,cls) { 
  47.  var reg = new regexp('(s|^)'+cls+'(s|$)'); 
  48.  ele.classname=ele.classname.replace(reg,' '); 
  49. // getoffset function copied from jquery lib (http://jquery.com/) 
  50. if (document.documentelement["getboundingclientrect"]){ 
  51.  // get offset using getboundingclientrect 
  52.  // http://ejohn.org/blog/getboundingclientrect-is-awesome/ 
  53.  var getoffset = function(el){ 
  54.   var box = el.getboundingclientrect(), 
  55.   doc = el.ownerdocument, 
  56.   body = doc.body, 
  57.   docelem = doc.documentelement, 
  58.    
  59.   // for ie  
  60.   clienttop = docelem.clienttop || body.clienttop || 0, 
  61.   clientleft = docelem.clientleft || body.clientleft || 0, 
  62.    
  63.   // in internet explorer 7 getboundingclientrect property is treated as physical, 
  64.   // while others are logical. make all logical, like in ie8.   
  65.    
  66.   zoom = 1; 
  67.    
  68.   if (body.getboundingclientrect) { 
  69.    var bound = body.getboundingclientrect(); 
  70.    zoom = (bound.right - bound.left)/body.clientwidth; 
  71.   } 
  72.    
  73.   if (zoom > 1){ 
  74.    clienttop = 0; 
  75.    clientleft = 0; 
  76.   } 
  77.    
  78.   var top = box.top/zoom + (window.pageyoffset || docelem && docelem.scrolltop/zoom || body.scrolltop/zoom) - clienttop, 
  79.   left = box.left/zoom + (window.pagexoffset|| docelem && docelem.scrollleft/zoom || body.scrollleft/zoom) - clientleft; 
  80.      
  81.   return { 
  82.    top: top, 
  83.    left: left 
  84.   }; 
  85.  } 
  86.   
  87. else { 
  88.  // get offset adding all offsets  
  89.  var getoffset = function(el){ 
  90.   if (w.jquery){ 
  91.    return jquery(el).offset(); 
  92.   }   
  93.     
  94.   

自学PHP网专注网站建设学习,PHP程序学习,平面设计学习,以及操作系统学习

京ICP备14009008号-1@版权所有www.zixuephp.com

网站声明:本站所有视频,教程都由网友上传,站长收集和分享给大家学习使用,如由牵扯版权问题请联系站长邮箱904561283@qq.com

添加评论