日期:2014-05-16 浏览次数:20744 次
<html> <head> <title>上传页面</title> <script type="text/javascript" src="js/upload.js"></script> </head> <body> <form id="uploadform" method="post" ENCTYPE="multipart/form-data"> <input onclick="show()" type="submit" value="上传" /> </form> <div style="width:200px;height:80px;background:yellow; float:left" id="uploadshow"></div> </body>
function createAjax(){ var request=false; //window对象中有XMLHttpRequest存在就是非IE,包括(IE7,IE8) if(window.XMLHttpRequest){ request=new XMLHttpRequest(); if(request.overrideMimeType){ request.overrideMimeType("text/xml"); } //window对象中有ActiveXObject属性存在就是IE }else if(window.ActiveXObject){ var versions=['Microsoft.XMLHTTP', 'MSXML.XMLHTTP', 'Msxml2.XMLHTTP.7.0','Msxml2.XMLHTTP.6.0','Msxml2.XMLHTTP.5.0', 'Msxml2.XMLHTTP.4.0', 'MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP']; for(var i=0; i<versions.length; i++){ try{ request=new ActiveXObject(versions[i]); if(request){ return request; } }catch(e){ request=false; } } } return request; } var ajax=null; function show(){ ajax=createAjax(); ajax.open("post", "program_upload.php",true); ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); ajax.send(document.getElementById("uploadform").submit()); //指定异步处理显示对象 var obj_uploadshow=document.getElementById("uploadshow"); //回调函数 ajax.onreadystatechange=function(){ obj_uploadshow.innerHTML='uploading..'; if(ajax.readyState==4 && ajax.status==200){ var file=ajax.responseText; eval("var obj="+file); var id = obj.id; var program_contentadd = obj.program_contentadd; var program_date = obj.program_date; var program_team = obj.program_team; var program_title = obj.program_title; var program_author = obj.program_author; var program_add = obj.program_add; var program_type = obj.program_type; function upload_sql(){ ajax=createAjax(); ajax.open("POST", "program_upload_sql.php",true); ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); ajax.send('id='+id+'&program_contentadd='+program_contentadd+'&program_date='+program_date+'&program_team='+program_team+'&program_title='+program_title+'&program_author='+program_author+'&program_add='+program_add+'&program_type='+program_type); if(ajax.responseText==null){ var continue_send;