上传.php
?>
index.html
var xhr;
function createXMLHttpRequest()
{
if(window.ActiveXObject)
{
xhr = new ActiveXObject("Microsoft.XMLHTTP");
}
else if(window.XMLHttpRequest)
{
xhr = new XMLHttpRequest();
}
}
function UpladFile()
{
var fileObj = document.getElementById("file").files[0];
var FileController = 'upload.php';
var form = new FormData();
form.append("myfile", fileObj);
createXMLHttpRequest();
xhr.onreadystatechange = handleStateChange;
xhr.open("post", FileController, true);
xhr.send(form);
}
function handleStateChange()
{
if(xhr.readyState == 4)
{
if (xhr.status == 200 || xhr.status == 0)
{
var result = xhr.responseText;
var json = eval("(" result ")");
图片图片 alert('链接:n' json.file) ;
}
}
}
脚本>
.txt{ height:28px;边框:1px实心#cdcdcd;宽度:670px;}
.mybtn{ 背景颜色:#FFF;行高:14px;垂直对齐:中间;边框:1px实线#CDCCDCD;高度:30px;宽度:70px;}
.file{ 位置:绝对;顶部:0;右:80px;高度:24px;滤镜:alpha(不透明度:0);不透明度:0;宽度:260px }