Skip to content

[4.x & 5.x]: Error when using Live Preview after uploading an asset #14832

@tommysvr

Description

@tommysvr

What happened?

Description

Getting an Uncaught (in promise) DOMException: Failed to set the 'value' property on 'HTMLInputElement': This input element accepts a filename, which may only be programmatically set to the empty string error when uploading an asset and then trying to preview an entry.

Steps to reproduce

  1. Click 'Upload Files' on an assets field
  2. Upload an image
  3. Click 'Preview'

Tested on a local filesystem, asset field settings are all set to the default. Dragging an image onto the field works without error.

Tested in Chrome, Safari and Firefox - the error differs slightly in each.

screenshot_2024_04_19._14.58-converted.2.mp4

Expected behavior

Live Preview loads correctly

Actual behavior

Live Preview window doesn't show, and this error is shown in the browser console:

jquery.js?v=1707205984:2 Uncaught (in promise) DOMException: Failed to set the 'value' property on 'HTMLInputElement': This input element accepts a filename, which may only be programmatically set to the empty string.
    at HTMLInputElement.<anonymous> (https://craft5.ddev.site/cpresources/624f2193/jquery.js?v=1707205984:2:67445)
    at Function.each (https://craft5.ddev.site/cpresources/624f2193/jquery.js?v=1707205984:2:3091)
    at T.fn.init.each (https://craft5.ddev.site/cpresources/624f2193/jquery.js?v=1707205984:2:1571)
    at T.fn.init.val (https://craft5.ddev.site/cpresources/624f2193/jquery.js?v=1707205984:2:67137)
    at Object.copyInputValues (https://craft5.ddev.site/cpresources/1ab53bc8/garnish.js?v=1711503619:2:112805)
    at s.constructor._getClone (https://craft5.ddev.site/cpresources/ef40e11e/cp.js?v=1713140127:2:632336)
    at s.constructor.open (https://craft5.ddev.site/cpresources/ef40e11e/cp.js?v=1713140127:2:622757)
    at s.constructor.<anonymous> (https://craft5.ddev.site/cpresources/ef40e11e/cp.js?v=1713140127:2:451105)
    at f (https://craft5.ddev.site/cpresources/ef40e11e/cp.js?v=1713140127:2:425357)
    at Generator.<anonymous> (https://craft5.ddev.site/cpresources/ef40e11e/cp.js?v=1713140127:2:426703)

Craft CMS version

Tested on 4.8.9 & 5.0.4

PHP version

8.2

Operating system and version

No response

Database type and version

MySQL 8.0

Image driver and version

No response

Installed plugins and versions

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions