我已经创建了一个HTML页面来上传文件。提交表单时,需要将其发送到URL:“ http://localhost:3030”上运行的TIBCO Web服务。我可以调用服务,但文件未发送到服务。
下面是我包含在HTML页面中的javascript代码。
function onSubmit( form ){
var url = "http://localhost:3030";
let orderfile = document.getElementById("uploadfile");
xmlhttp = new XMLHttpRequest();
let formData = new FormData();
formData.append("webmasterfile", orderfile);
xmlhttp.open("POST", url, true);
xmlhttp.onreadystatechange = function () { //Call a function when the state changes.
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
alert(xmlhttp.responseText);
}
}
xmlhttp.send(formData);
resetForm();
}
function resetForm(){
document.getElementById("myForm").reset();
}
HTTP服务应该在mime部分中获取文件。但是,事实并非如此。