Skip to content

ImageField overwrites existing images #7525

@tentwofour

Description

@tentwofour

Describe the bug

This is explained and has a PR, but the issue was closed without merge: #5321. The issue still exists in 4.29.0

To Reproduce

  • Define an ImageField, and call the required setUploadDir()
ImageField::new('image')
    ->setUploadDir('/public/uploads/')
    ->setBasePath('/uploads/')
  • The filename passed by StringToFileTransformer#doReverseTransform doesn't pass the full path to the file to the upload_validate callable of FileUploadType, so there will be no "_x" appended to the filename, which overwrites the existing file.

(OPTIONAL) Additional context

I've tested the PR above locally, and it resolves the issue, aside from the line numbers changing since the original PR was created.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions