Html:
<div>
<form enctype="multipart/form-data" action="upload/" method="POST" target="hidden_frame_apk">
<input type="file" name="file"/>
<input id="input_gameId_apk" type="hidden" name="gameId" value=""/>
<input type="hidden" name="type" value="apk"/>
<input id="updata_btn_apk" class=" btn" type="submit" value="上传文件"/>
</form>
<iframe name='hidden_frame_apk' id="hidden_frame_apk" style='display: none'></iframe>
</div>
JavaScript:
let updata_btn_apk = document.getElementById("updata_btn_apk");
updata_btn_apk.onclick=function (){
let hidden_frame = document.getElementById("hidden_frame_apk");
hidden_frame.onload = function () {
//上传结果处理;
let body = hidden_frame.contentDocument.body.innerText;
getParentPackage(gameId);
alert(body);
};
};
本文介绍了一个使用HTML和JavaScript实现文件上传的功能示例。通过一个包含文件输入字段的表单,用户可以选择文件进行上传。JavaScript负责监听提交按钮并处理上传后的响应。
853

被折叠的 条评论
为什么被折叠?



