Knowledge Base
Published Mar. 25, 2026

Avoiding Empty File Uploads in Documents and Media

Written By

Attila Csogor

How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!

While we make every effort to ensure this Knowledge Base is accurate, it may not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with any feedback or concerns.

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:

  1. In Documents and Media, open the upload dialog.

  2. Fill in all metadata fields (e.g., Title, Description) before selecting the file. This ensures no validation errors will occur later.

  3. Select the file from your local system as the final step.

  4. Click Publish.

By providing all metadata first, you can avoid validation-triggered refreshes that would clear your selected file. 

Did this article resolve your issue ?

Knowledge Base