Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When I attempt to upload a file into a required file or image field whose extension isn't in the list of allowed extensions I get the following error:
The specified file views.view_.content.yml could not be uploaded.
Only files with the following extensions are allowed: png gif jpg jpeg.
This value should not be null.
The odd thing is the last part: "This value should not be null."
Comment | File | Size | Author |
---|---|---|---|
#9 | Screenshot 2020-06-11 09.16.13.png | 26.26 KB | pameeela |
drupal-8-image-upload-invalid-ext.png | 16.89 KB | rooby |
Comments
Comment #2
ajalan065 CreditAttribution: ajalan065 at Google Summer of Code commentedIMHO, this field is a required one, and when we upload a file with the unacceptable extension and submit the form. The validation discards the file uploaded, resulting this field to attain null value, hence this error.
Please correct me if I am wrong.
Comment #3
mondrakeRelated (I think) #2377747: Incorrect node create validation error when an invalid image is attached to a field
Comment #4
rooby CreditAttribution: rooby commentedI can confirm that if I make the field optional then the last part of the message ("This value should not be null.") is no longer there.
Comment #5
rooby CreditAttribution: rooby commentedThis also happens for required file fields.
Comment #6
ajalan065 CreditAttribution: ajalan065 at Google Summer of Code commentedThis shows that the required field has NOT NULL attribute in the database as is in most of the cases.
Comment #7
dhiraj bhagat CreditAttribution: dhiraj bhagat as a volunteer and commentedHave you fixed this issue I am getting same issue. I am unable to upload any file.
Comment #8
david.fcondezo CreditAttribution: david.fcondezo as a volunteer commentedDid anybody find a solution for this?
Comment #9
pameeela CreditAttribution: pameeela commentedI'm unable to reproduce this on 9.0.0. Screenshot attached, "This value should not be null." is no longer appearing.
@rooby, I'm going to close this as cannot reproduce given that it can't be reproduced any longer. I suspect it was fixed as a result of a change somewhere else, probably in #2377747: Incorrect node create validation error when an invalid image is attached to a field.
If anyone else is still able to produce this error, please re-open this ticket with complete steps to reproduce the issue (starting from "Install Drupal core"), document those steps in the issue summary and set the issue status back to "Active".
Comment #10
pameeela CreditAttribution: pameeela commented