Downloading only a specific file type using jsp

The following HTML element allows you to download all types of files.

<input type="file" name="fileUploaded"/>

I want to limit the file type only .txt, how do I achieve this?

I use the Apache Commons FileUpload API and Spring framework.

+3
source share
1 answer

Take a look

http://www.uploadify.com/demos/

This is a JavaScript-based solution that a Flash-based loader generates.

Here's what they did in the second demo (user demo):

$(function() {
    $('#custom_file_upload').uploadify({
      'uploader'       : '/uploadify/uploadify.swf',
      'script'         : '/uploadify/uploadify.php',
      'cancelImg'      : '/uploadify/cancel.png',
      'folder'         : '/uploads',
      'multi'          : true,
      'auto'           : true,
      'fileExt'        : '*.jpg;*.gif;*.png',
      'fileDesc'       : 'Image Files (.JPG, .GIF, .PNG)',
      'queueID'        : 'custom-queue',
      'queueSizeLimit' : 3,
      'simUploadLimit' : 3,
      'removeCompleted': false,
      'onSelectOnce'   : function(event,data) {
          $('#status-message').text(data.filesSelected + ' files have been added to the queue.');
        },
      'onAllComplete'  : function(event,data) {
          $('#status-message').text(data.filesUploaded + ' files uploaded, ' + data.errors + ' errors.');
        }
    });
+1
source

Source: https://habr.com/ru/post/1793593/


All Articles