question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Invalid file types are correctly not added to the model but turn the form invalid

See original GitHub issue

So I have this snippet which actually works fine adding multiple files on multiple drags/selects, until I add an invalid file type. The invalid file type is not added to the model but will make the form invalid. The form becomes valid again when I add/append another valid file to the list. I tried put allowInvalid false, ngf-valid-only but none of them solve my problem. Always get the form.files.$error = {“pattern”:true} when adding an invalid file. How can I make these unsupported file types not turn the form invalid?

<div name="files" ngf-drop ngf-select ng-model="ui.files" class="drop-box"  
   ng-model-options="{allowInvalid: false}"
   ngf-drag-over-class="{accept:'dragover', reject: 'reject-dragover'}" 
   ngf-multiple="true" ngf-allow-dir="true"
   accept="{{ui.validFileTypes}}" ngf-keep="true" ngf-valid-only="true"
   ngf-change="filesChanged()"
   ngf-pattern="ui.validFileTypes" required>
</div>

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:5
  • Comments:19 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
jonathan-chincommented, Sep 5, 2016

I was still having trouble with ngf-ignore-invalid. invalid files weren’t being added but the form was still being set as invalid. I checked the source and found a logic typo.

#1685 should fix it

now, if there were a way to ignore invalid files (not validate them) but still give a message? I’ve tried other fixes in the forums but my form has other fields in it that I want to check.

0reactions
dimorenocommented, Jul 26, 2017

@danialfarid How can I show my images thumbnail. for example I have this https://es.stackoverflow.com/questions/90609/error-al-mostrar-preview-de-imagen-en-angularjs `

<div class="row"> <div class="col s12 m12 hide-on-med-and-down"> <div class="image-upload"> <label for="file-input"> photo_camera Agrega imagen 1... </label> </div> </div> <div class="col s12 m12 hide-on-med-and-down"> <div class="image-upload"> <label for="file-input"> photo_camera Agrega imagen 2... </label> </div> </div> </div>

` I want to show thumbnail of 2 images but always show in ng-model number 1 How can I fix that?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Vue vuelidate not working file type input - Stack Overflow
But it's not working in form upload file validation. Because file type input can't set v-model attribute and I have the below error...
Read more >
Invalid File Type - CoSchedule Support
If the file is a different type, you will receive the Invalid File Type error: "When uploading a file, it must be the...
Read more >
How to Fix the “Sorry, This File Type Is Not Permitted for ...
This is an easy first step: If the file name extension is incorrect, then you can fix it and upload the file in...
Read more >
Excel cannot be open the file 'filename.xlsx' because the file ...
Hi All, I have a excel.xlsx file saved in my system which has been corrupted . ... because the file format or file...
Read more >
How to Change the Allowed File Types in the File Upload ...
But you can add or remove file types whenever you want. ... form-file-upload-invalid-extension-error-min.png. How did it go?
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found