Issue
When uploading a file in Documents and Media, a form refresh (e.g., by changing the Document Type or triggering a metadata validation error) causes the selected file to be cleared from the input field. Despite the file no longer being attached, the form can be submitted. This results in a "successful" upload and creation of a file entry with no content.
Environment
-
Liferay DXP 7.4+
-
Liferay DXP Quarterly Releases
Resolution
This behavior results from a combination of browser security restrictions and the current design and status of the Documents and Media application.
-
Browser Security: Web browsers intentionally prevent file input fields (
<input type="file">) from being automatically re-populated after a form refresh. This is a security measure to prevent unintended access to a user's local files. -
Product Status: The Documents and Media application is in maintenance mode, which means new feature enhancements are not planned. The new Liferay Content Management System was introduced in 2026.Q1.X and is planned to make this field required for the basic document asset type, which will resolve the issue.
Workaround
To prevent the form from refreshing after a file has been selected, follow these steps:
-
In Documents and Media, open the upload dialog.
-
Fill in all metadata fields (e.g., Title, Description) before selecting the file. This ensures no validation errors will occur later.
-
Select the file from your local system as the final step.
-
Click Publish.
By providing all metadata first, you can avoid validation-triggered refreshes that would clear your selected file.