What we usually do is upload files. The upload folder is similar to the upload file, but there are some differences. This time we made the upload folder and record it for later use.
The first thing we need to understand is the three elements of uploading files:
1. Form submission method: post (get method submission has a size limit, post does not)
2. The enctype attribute of the form: must be set to multipart/form-data.
3. The form must have a file upload item: file, and the file item needs to be given a name value
The upload folder needs to add an attribute webkitdirectory, like this:
<input id="fileFolder" name="fileFolder" type="file" webkitdirectory>
In js, you can judge whether the number of files in the folder and the size of the folder meet the requirements, and you cannot submit to the background if they do not meet the requirements:
Front HTML template
The logic of selecting files, selecting folders, pasting files and folders
The difference when receiving folders in the background is that MultipartHttpServletRequest is needed
Packages and classes on the server side
The processing logic of f_post.jsp page
The logic of generating file names
The following is the processing done by the service layer:
The overall module is divided as follows:
The data type entity logic is processed as follows
The logic in the backend database basically uses the above entity classes
The file data table operation class is as follows
The overall effect after implementation is as follows
Effect after uploading the folder
The folder data saved by the server, and the hierarchical structure is consistent with that of the local client. This is very useful when used in an OA system or a network disk system
Most of the back-end code logic is the same, and it currently supports MySQL, Oracle, and SQL. You need to configure the database before use, you can refer to this article I wrote: http://blog.ncmem.com/wordpress/2019/08/12/java-http%E5%A4%A7%E6%96%87 %E4%BB%B6%E6%96%AD%E7%82%B9%E7%BB%AD%E4%BC%A0%E4%B8%8A%E4%BC%A0/
Welcome to join the group to discuss together: 374992201