Input of type file that automatically selects files?

1

I have a input of type file and with the property multiple , that is I can select several files. Specifically, I need to send three types of files to the server:

 1. archivo.shp
 2. archivo.shx
 3. archivo.dbf

I would like that in the menu to choose input files when selecting any of the previous files, automatically select the others (if they exist). That is, if I select archivo.shp , I also select archivo.shx and archivo.dbf if they exist in the same path as file.shp.

How could I implement something like this with JavaScript?

    
asked by Jose Hermosilla Rodrigo 02.11.2016 в 22:34
source

2 answers

2

According to the documentation this can not be done for security

  

The file input type creates a field through which users can upload files from their local computer or network. The VALUE attribute specifies the name of the initial file, but it is typically ignored by browsers as a security precaution.

     

File type input is an entry point for the user to upload files from their local or network computer. The VALUE of the attribute specifies the name of the initial file, but is normally ignored by the navigator for security reasons.

    
answered by 02.11.2016 / 22:45
source
0
  • you should check if the file exists!
  • function fileExists(path) {
      try {
        if(fs.accessSync('/nombre del archivo')) {
          return true;
        }
      } catch (e) {
        return false;
      }
    }
    

    then change the format of your .shp file to .shx and .dbf

    and use the function above to check if there are those files with different format.

        
    answered by 02.11.2016 в 22:41