我试图实现一个file uploadAPI,在这里给出: Mediafirefile upload 我成功地能够上载Post数据和获取数据 ,但是不知道如何发送x-filename属性,这个属性是API指南中给出的Header数据 。 我的代码: xmlhttp=new XMLHttpRequest(); var formData = new FormData(); formData.append("Filedata", document.getElementById("myFile").files[0]); var photoId = getCookie("user"); // formData.append("x-filename", photoId); //tried this but doesn't work // xmlhttp.setRequestHeader("x-filename", photoId); //tried this too (gives error) [edited after diodeous' answer] xmlhttp.onreadystatechange=function() { alert("xhr status : "+xmlhttp.readyState); } var url = "http://www.mediafire.com/api/upload/upload.php?"+"session_token="+getCookie("mSession")+"&action_on_duplicate=keep"; xmlhttp.open("POST", url); // […]