How to check if a file has been selected after it is still in the directory in JavaScript

1

In my application I use the javascript framework as javascript, and to select the files I use the following button:

 <md-button class="md-accent md-raised button-arquivo-margin"
                   ng-disabled="vm.controladorRequisicao.requisicaoSolicitada"
                   aria-label="Arquivo(s)">
            <div layout="row"
                 layout-align="center start"
                 flex>
                <input class="input-selecao"
                       im-file-change="vm.metodos.selecionarArquivos($event, arquivos)"
                       type="file"
                       multiple />
                <i class="icon-file s30"></i>
                <span class="title">Arquivo(s)</span>
            </div>
 </md-button>

where im-file-change="vm.metodos.selecionarArquivos($event, arquivos)" is only a directive that gets the input event files and binds with my model. After selecting the files they are displayed in a table as shown below:

But I'm having a bad system usability problem, in which people are moving or deleting the files before sending them to the API, so when trying to send the files cause a problem ... And I did the checks the request does not then only complete a request undefined ...

I wonder if it is possible to consist in some way if the files exist in the folder. So, before sending, I would check if the files exist in the folder and if they do not exist, it could inform the user that the files have been moved or deleted from the current folder.

    
asked by anonymous 05.07.2018 / 17:13

1 answer

1

Can solve my problem as follows. When files are moved or deleted from the folder where they were selected, in event.target.files of the selection and bind input of the model with angularJS, the size of the selected files is zeroed, as can be seen in the image below:

So I created a simple method that will always consist of the size of the files before sending them:

function _consistirArquivos(arquivos) {
        var verificadorArquivosIncosistentes = false;
        for (let i = 0; i < arquivos.length; i++) {
            var arquivo = arquivos[i];
            if (arquivo.size == 0) {
               verificadorArquivosIncosistentes  = true;
               break;                        
            }
        }
        return verificadorArquivosIncosistentes                            
};
    
05.07.2018 / 17:13