可能有重复的可能性...但我没有得到任何答案
如何让用户在单击“下载”按钮时选择下载路径?
我只需要在我的 Web 应用程序中使用该文件夹路径。
任何解决方案将不胜感激。
我也使用jquery来获得下载路径。
创建 HTML 表单:
<form id="downloadForm">
<label for="downloadPath">Select Download Folder:</label>
<input type="file" id="downloadPath" webkitdirectory directory multiple style="display: none;">
<button type="button" id="downloadButton">Download</button>
</form>
添加 jQuery 来处理用户交互:
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
$(document).ready(function () {
// When the "Download" button is clicked, trigger the file input click event
$("#downloadButton").click(function () {
$("#downloadPath").click();
});
// When the user selects a directory, store the path in a variable
$("#downloadPath").change(function () {
var selectedPath = $(this).val();
// You can now use 'selectedPath' in your web application as needed
console.log("Selected path: " + selectedPath);
});
});
</script>