I require a browse button on my JSP page that allows users to select folders, not individual files

In search of ideas for my JSP page, I am looking to browse a folder rather than just a file. Can anyone assist with this requirement?

Answer №1

Have you heard about the HTMLInputElement.webkitdirectory attribute for enhancing the functionality of the input element? While it's a non-standard feature, make sure to include a fallback when implementing it.

Check out this code snippet:

function handleFolderChange({ target }) {

  const files = target.files;

  // Since file is a FileList and array methods are not directly supported.
  [...files].forEach(console.log); // Consider using a recursive function if 'file' could have another FileList (representing a folder)

}

const folderInput = document.getElementById("folderInput");

folderInput.addEventListener('change', handleFolderChange);
<label>
   Select a folder
   <input id="folderInput" type="file" webkitdirectory directory multiple>
</label>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Executing Multiple Requests Concurrently in Angular 5 using forkJoin Technique

Important Note The issue lies in the backend, not Angular. The requests are correct. In my Angular5 app, I am trying to upload multiple files at once using rxjs forkJoin. I store the requests in an array as shown in the code below. However, after adding ...

While attempting to make my div responsive, it unexpectedly became stuck to the navbar

After successfully creating a website that works fine on desktop, I encountered an issue when viewing it on my phone. The main content section, which features jokes, gets scrolled up along with the navbar. I followed a tutorial on YouTube to make the navba ...

HTML5 document type declarations

After switching my site's doctype from XHTML to HTML5, I have made the following changes: I currently have: <!DOCTYPE html> <html lang="en-GB" xml:lang="en-GB" dir="ltr" xmlns="http://www.w3.org/1999/xhtml"> Now my question is, do I sti ...

What are the solutions to troubleshoot the image and column flexbox issue in Internet Explorer?

I've created a flexible template using bootstrap4 CSS that works well in all browsers except IE 11.0. The issue seems to be with the .d-flex class, which I used to ensure that all my columns have the same height. I've tried finding a solution on ...

Images displayed in the Slick carousel are automatically given a stylish padding

I'm facing an issue with my slick-carousel where there seems to be a large padding on the right side of the images, extending all the way up to the next product image. I've tried removing margins and paddings from my code but it hasn't resol ...

The setInterval function appears to only run once in Chrome, but is functioning properly in all other browsers

Check out the slideshow code below: HTML <div id="slideshow"><img src="common/images/background/Slide1b.jpg" /> <img src="common/images/background/Slide2b.jpg" /> <img src="common/images/background/Slide3b.jpg" /> <img ...

Is the background image unable to fill up the entire screen?

I'm currently facing an issue with my webpage's background not covering the entire vertical space. Despite trying different solutions and referring to previous posts, I haven't been able to resolve it yet. Here is the relevant code: <div ...

` `Display issue: Internet Explorer 11 concealing element with scroll bar

I encountered an issue on Internet Explorer 11 where I am unable to click on an element that is positioned fixed and aligned to the right; the scroll bar hides the element. I am using the Bootstrap framework. Any suggestions? https://i.sstatic.net/TqDi ...

Utilizing Gulp locally without the need for global installation or referencing the bin js file

I have a gulpfile.js that runs perfectly when I type 'gulp' into the command line. Essentially, the 'gulp' bash command just calls the specific js file outlined in 'package.json >> bin >> gulp' of the globally ins ...

"Using the fetch Prototype.json() method can lead to the alteration or corruption of the

For the past week, I've been struggling with a seemingly impossible issue in my Javascript code: The problem arises when trying to retrieve data from the server using fetch: fetch(this.props.url, { method: 'POST', b ...

Is Python being used to track NBA.com stats?

Does anyone have any advice on how to extract NBA.com "tracking" stats using a python script and display them in a simple table? I'm particularly struggling with this specific section of stats on the site. Accessing stats directly from NBA.com can be ...

When attempting to use the .split method, an error is thrown stating that addEventListener is not

I'm attempting to create a table that automatically fills in the next input when I select options from MySQL. However, when I run this code, I get an error saying "addEventListener is not a function." I'm not very familiar with JavaScript, so I&a ...

Using ng-repeat with ng-model; accessing the value of ng-model

I find myself in a peculiar situation - Behold the Controller snippet - $scope.filterNum = {0: 'filterVal1', 1: 'filterVal2', 2: 'filterVal3', 3: 'filterVal4', 4: 'filterVal5', 5: 'filterVal6', ...

Navigating through the complexities of managing asynchronous props and state in React-components

I'm really struggling to understand this concept. My current challenge involves passing asynchronously fetched data as props. The issue is that the props themselves are also asynchronous. Below is a simplified version of the component in question: i ...

angularjs: hide div based on text entered in textfield

Is there a way to hide a div (with the class "card") until the user inputs text into the textfield in an AngularJS application? I believe the solution involves using ng-show, but I'm unsure of how to implement this functionality. Any assistance would ...

What is the best way to smoothly reveal images one by one?

My goal is to smoothly slide three images inside a div, one by one. However, I'm facing an issue where the images stack on top of each other and end up stuck in their original positions. Here is the code snippet I've been working with: <div ...

What is the best way to make a div stick to the inside of another div with Bootstrap?

As a newcomer to Bootstrap 4, I am curious if there is a way to affix a div to the bottom of its parent div. My structure involves using the classes .container within a .row, along with several child divs: <div class='container'> <d ...

Unable to activate primary error handler in my Node.js Express application

I have implemented node express (4.15.2) and used the default error handler provided by the express generator function to manage errors. Here is the code snippet: const app = express(); app.set('port', config.enviroment.portNumber); app.use(log ...

Styling links conditionally in a React component

How can I style the page title in my nav bar when I am on the selected path? I am using React and Tailwind CSS. For example, I want the title to turn yellow when I am on the current page. Here is the logic I have tried, but it doesn't seem to be work ...

When working on one of my subdomains, I require the ability to distribute cookies between the two

Currently, I am involved in a project that utilizes a sub-domain under a parent domain called "my-project.parent.com", which unfortunately I do not have access to. Additionally, there is another project operating under the main domain "parent.com" with t ...