嗨我有一个JSP文件,其中有两个输入框一个文件类型另一个是文件类型隐藏和alsotwo按钮一个用于浏览和加载按钮。如果我单击jS中的按钮我已经调用文件输入框来浏览该文件,但当试图在输入框中填充文件路径时,将其视为假路径。为什么JavaScript将文件路径作为JSP中的假路径?
下面是我的代码。可以任何机构告诉如何解决这个问题在JSp?
<script type='text/javascript'>
function fileupload() {
$('#excelfile').click();
}
function Populateinput() {
var filePath = $('#excelfile').val();
//alert(filePath);
document.getElementById("filename").value = filepath;
}
</script>
<div>
<label style="color: black;">Excel Input:</label>
<input type="text" readonly="readonly" id="filename" name="filename">
<button type="button" value="Browse" onclick="fileupload();" style="color: black;">Browse</button>
<input type="submit" value="Load" style="color: black;" value="Load">
<input type="file" id="excelfile" name="excelfile" style="display: none;" onchange="Populateinput();">
</div>
未经允许,用户不得诱使用户选择文件。安全问题,即使你的用例是合法的。 –