网站地图    收藏   

主页 > 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. /** 
  19.  * attaches event to a dom element 
  20.  */ 
  21. function addevent(el, type, fn){ 
  22.  if (w.addeventlistener){ 
  23.   el.addeventlistener(type, fn, false); 
  24.  } else if (w.attachevent){ 
  25.   var f = function(){ 
  26.     fn.call(el, w.event); 
  27.   };    
  28.   el.attachevent('on' + type, f) 
  29.  } 
  30. } 
  31.  
  32. /** 
  33.  * creates and returns element from html chunk 
  34.  */ 
  35. var toelement = function(){ 
  36.  var div = d.createelement('div'); 
  37.  return function(html){ 
  38.   div.innerhtml = html; 
  39.   var el = div.childnodes[0]; 
  40.   div.removechild(el); 
  41.   return el; 
  42.  } 
  43. }(); 
  44. function hasclass(ele,cls){ 
  45.  return ele.classname.match(new regexp('(s|^)'+cls+'(s|$)')); 
  46. } 
  47. function addclass(ele,cls) { 
  48.  if (!hasclass(ele,cls)) ele.classname += " "+cls; 
  49. } 
  50. function removeclass(ele,cls) { 
  51.  var reg = new regexp('(s|^)'+cls+'(s|$)'); 
  52.  ele.classname=ele.classname.replace(reg,' '); 
  53. } 
  54. // getoffset function copied from jquery lib (http://jquery.com/) 
  55. if (document.documentelement["getboundingclientrect"]){ 
  56.  // get offset using getboundingclientrect 
  57.  // http://ejohn.org/blog/getboundingclientrect-is-awesome/ 
  58.  var getoffset = function(el){ 
  59.   var box = el.getboundingclientrect(), 
  60.   doc = el.ownerdocument, 
  61.   body = doc.body, 
  62.   docelem = doc.documentelement, 
  63.    
  64.   // for ie  
  65.   clienttop = docelem.clienttop || body.clienttop || 0, 
  66.   clientleft = docelem.clientleft || body.clientleft || 0, 
  67.    
  68.   // in internet explorer 7 getboundingclientrect property is treated as physical, 
  69.   // while others are logical. make all logical, like in ie8.   
  70.    
  71.   zoom = 1; 
  72.    
  73.   if (body.getboundingclientrect) { 
  74.    var bound = body.getboundingclientrect(); 
  75.    zoom = (bound.right - bound.left)/body.clientwidth; 
  76.   } 
  77.    
  78.   if (zoom > 1){ 
  79.    clienttop = 0; 
  80.    clientleft = 0; 
  81.   } 
  82.    
  83.   var top = box.top/zoom + (window.pageyoffset || docelem && docelem.scrolltop/zoom || body.scrolltop/zoom) - clienttop, 
  84.   left = box.left/zoom + (window.pagexoffset|| docelem && docelem.scrollleft/zoom || body.scrollleft/zoom) - clientleft; 
  85.      
  86.   return { 
  87.    top: top, 
  88.    left: left 
  89.   }; 
  90.  } 
  91.   
  92. } else { 
  93.  // get offset adding all offsets  
  94.  var getoffset = function(el){ 
  95.   if (w.jquery){ 
  96.    return jquery(el).offset(); 
  97.   }   
  98.     
  99.   

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

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

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

添加评论