嗨我有一個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>
未經允許,用戶不得誘使用戶選擇文件。安全問題,即使你的用例是合法的。 –