ajax php教程多文件上传代码 (function(){ var d = document, w = window; /** * get element by id */ function get(element){ if (typeof element == "string") element = d.getelementbyid(element); return element; } /** * attaches event to a dom element */ function addevent(el, type, fn){ if (w.addeventlistener){ el.addeventlistener(type, fn, false); } else if (w.attachevent){ var f = function(){ fn.call(el, w.event); }; el.attachevent('on' + type, f) } } /** * creates and returns element from html chunk */ var toelement = function(){ var div = d.createelement('div'); return function(html){ div.innerhtml = html; var el = div.childnodes[0]; div.removechild(el); return el; } }(); function hasclass(ele,cls){ return ele.classname.match(new regexp('(s|^)'+cls+'(s|$)')); } function addclass(ele,cls) { if (!hasclass(ele,cls)) ele.classname += " "+cls; } function removeclass(ele,cls) { var reg = new regexp('(s|^)'+cls+'(s|$)'); ele.classname=ele.classname.replace(reg,' '); } // getoffset function copied from jquery lib (http://jquery.com/) if (document.documentelement["getboundingclientrect"]){ // get offset using getboundingclientrect // http://ejohn.org/blog/getboundingclientrect-is-awesome/ var getoffset = function(el){ var box = el.getboundingclientrect(), doc = el.ownerdocument, body = doc.body, docelem = doc.documentelement, // for ie clienttop = docelem.clienttop || body.clienttop || 0, clientleft = docelem.clientleft || body.clientleft || 0, // in internet explorer 7 getboundingclientrect property is treated as physical, // while others are logical. make all logical, like in ie8. zoom = 1; if (body.getboundingclientrect) { var bound = body.getboundingclientrect(); zoom = (bound.right - bound.left)/body.clientwidth; } if (zoom > 1){ clienttop = 0; clientleft = 0; } var top = box.top/zoom + (window.pageyoffset || docelem && docelem.scrolltop/zoom || body.scrolltop/zoom) - clienttop, left = box.left/zoom + (window.pagexoffset|| docelem && docelem.scrollleft/zoom || body.scrollleft/zoom) - clientleft; return { top: top, left: left }; } } else { // get offset adding all offsets var getoffset = function(el){ if (w.jquery){ return jquery(el).offset(); } var top = 0, left = 0; do { top += el.offsettop || 0; left += el.offsetleft || 0; } while (el = el.offsetparent); return { left: left, top: top }; } } function getbox(el){ var left, right, top, bottom; var offset = getoffset(el); left = offset.left; top = offset.top; right = left + el.offsetwidth; bottom = top + el.offsetheight; return { left: left, right: right, top: top, bottom: bottom }; } /** * crossbrowser mouse coordinates */ function getmousecoords(e){ // pagex/y is not supported in ie // http://www.quirksmode.org/dom/w3c_css教程om.html if (!e.pagex && e.clientx){ // in internet explorer 7 some properties (mouse coordinates) are treated as physical, // while others are logical (offset). var zoom = 1; var body = document.body; if (body.getboundingclientrect) { var bound = body.getboundingclientrect(); zoom = (bound.right - bound.left)/body.clientwidth; } return { x: e.clientx / zoom + d.body.scrollleft + d.documentelement.scrollleft, y: e.clienty / zoom + d.body.scrolltop + d.documentelement.scrolltop }; } return { x: e.pagex, y: e.pagey }; } /** * function generates unique id */ var getuid = function(){ var id = 0; return function(){ return 'valumsajaxupload' + id++; } }(); function filefrompath(file){ return file.replace(/.*(/|)/, ""); } function getext(file){ return (/[.]/.exec(file)) ? /[^.]+$/.exec(file.tolowercase()) : ''; } /** * cross-browser way to get xhr object */ var getxhr = function(){ var xhr; return function(){ if (xhr) return xhr; if (typeof xmlhttprequest !== 'undefined') { xhr = new xmlhttprequest(); } else { var v = [ "microsoft.xmlhttp", "msxml2.xmlhttp.5.0", "msxml2.xmlhttp.4.0", "msxml2.xmlhttp.3.0", "msxml2.xmlhttp.2.0" ]; for (var i=0; i = box.left) && (c.x = box.top) && (c.y
php #file_upload.php 2009-11-06
$file_path = '../../../uploads/';
$file_up = $file_path.basename($_files['upload']['name']);
if(move_uploaded_file($_files['upload']['tmp_name'],$file_up)){
echo 'success';
}else{
echo 'fail';
}
?>
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号