0

ドキュメントが非同期でアップロードされるように、サイトのアップロード ページを作成したいと考えています。 、JQuery を使用せずにこれを簡単に行う方法についての提案をお願いします。また、ファイルのアップロードの進行状況を監視して、進行状況バーをサイトに追加できるようにする方法があるかどうかも知りたいです。

function createXMLHttpRequestObject(){
var xmlHttp     =   3;

if(window.ActiveXObject){
    try{
        //test for new version of internet Explorer
        xmlHttp     =   new ActiveXObject("Msxml.XMLHTTP");
    }
    catch(e){
        try{
            xmlHttp     =   new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch(e){
            xmlHttp =   2;
        }
    }
}

else{
    try{
        xmlHttp =   new XMLHttpRequest();
    }
    catch(e){
        xmlHttp =   1;
    }

}

if(!xmlHttp){
    alert("Error creating Objece");
}
else{
    var xHttpArr = new Array();
    xHttpArr.push(xmlHttp);
    var i = xHttpArr.length - 1;
    return xHttpArr[i];
}
}

function process(xmlHttp, i){
if(xmlHttp.readyState   == 4 || xmlHttp.readyState  == 0){
    //value =   encodeURIComponent( objRef.value );

    xmlHttp.open("GET", "php/AjaxBody.php?value="+i, true);
    xmlHttp.onreadystatechange  =   handleServerResponse;
    xmlHttp.send(null);
}
else{
    alert("Hold on");
}
}



function handleServerResponse(){

if(test.readyState == 1 || test.readyState == 2 || test.readyState == 3){

}

if (test.readyState == 4){
    if(test.status == 200){
        txtResponse =   test.responseText;
        bodyDiv =   document.getElementById("body");
        bodyDiv.innerHTML   =   txtResponse;

    }
    else{
        alert("Error with the xmlHttp status");
    }
}
/*
else{
    alert("Error with the xmlHttp readystate: " + x.status);
} */
}

上記はオブジェクトを作成するコードです

    button.onclick = function() {
    send = createXMLHttpRequestObject();
    frmUpload = document.getElementById("frmUpload");
    file = document.getElementById("fileUpload");
    processSending(send, frmUpload);
}

上記のプロセスメソッドが呼び出されてファイルを送信すると、サーバーでファイルパスをエコーし​​ようとすると、次のように名前だけが表示されます

<?php
echo $_GET['value'];
?>
4

2 に答える 2