gpt4 book ai didi

javascript - 我在输入文件类型中看不到浏览按钮

转载 作者:太空宇宙 更新时间:2023-11-04 15:57:50 26 4
gpt4 key购买 nike

我通过 javascript 创建了一个输入文件类型。

除了我看不到浏览按钮外,输入类型文件按我的预期生成。

我搜索了输入文件类型的 css 样式,但我看到的只是如何自定义

浏览器按钮。下面是我的屏幕的样子。

enter image description here

通常情况下,文件类型应该显示为第二个,但我得到的是第一个

在 javascript 中生成一个文件类型。下面是我的代码。

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<style>
.uploadForm{
type:file; position:relative;
}

#addBtn{
width:100px; height:20px;
}
</style>
<script>
function addMoreFiles(){
var fileForm = document.createElement('input');
var addButton = document.createElement('button');
addButton.setAttribute('onclick', "addMoreFiles()");
addButton.setAttribute('id', "addBtn");
fileForm.className = 'uploadForm';
document.getElementById('uploadDiv').appendChild(fileForm);
document.getElementById('uploadDiv').appendChild(addButton);
}
</script>
</head>
<body onload="addMoreFiles()">
<form name="frmname" method="post" enctype="multipart/form-data" action="./ViewPage.jsp">
file<br>
<div id="uploadDiv"></div>
<br>
<input type="file" name="uploadFile"><br>
<input type="submit" value="upload"><br>
</form>
</body>
</html>

谁能告诉我我做错了什么?提前致谢。

最佳答案

var fileForm = document.createElement('input');
fileForm.type = 'file'; // only <input type="file"> has browse button

关于javascript - 我在输入文件类型中看不到浏览按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10222819/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com