日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

js 即时上传php_php+js实现异步图片上传实例分享

發布時間:2024/8/23 46 豆豆
生活随笔 收集整理的這篇文章主要介紹了 js 即时上传php_php+js实现异步图片上传实例分享 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
Html5 Ajax 上傳文件

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; border:1px solid #cdcdcd; width:670px;}

.mybtn{ background-color:#FFF; line-height:14px;vertical-align:middle;border:1px solid #CDCDCD;height:30px; width:70px;}

.file{ position:absolute; top:0; right:80px; height:24px; filter:alpha(opacity:0);opacity: 0;width:260px }

圖片

瀏覽...

上傳

總結

以上是生活随笔為你收集整理的js 即时上传php_php+js实现异步图片上传实例分享的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。