Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH leverage FormData to support file upload #1854

Open
wants to merge 3 commits into
base: 2.3
Choose a base branch
from

Conversation

lekoala
Copy link
Contributor

@lekoala lekoala commented Nov 15, 2024

Description

Currently, ajax forms are submitted using serializeArray. This doesn't allow sending more advanced content, like a file upload

Manual testing steps

  • Add a FileField in the cms
  • Check that $_FILES is empty on save

With this change, files are submitted properly. It also offers the opportunity to do more advanced things (eg: sending binary canvas data as a blob) and, all things considered, should probably work better because it uses a native js feature instead of jquery serializeArray

Issues

#1852

Pull request checklist

  • The target branch is correct
  • All commits are relevant to the purpose of the PR (e.g. no debug statements, unrelated refactoring, or arbitrary linting)
    • Small amounts of additional linting are usually okay, but if it makes it hard to concentrate on the relevant changes, ask for the unrelated changes to be reverted, and submitted as a separate PR.
  • The commit messages follow our commit message guidelines
  • The PR follows our contribution guidelines
  • Code changes follow our coding conventions
  • This change is covered with tests (or tests aren't necessary for this change)
  • Any relevant User Help/Developer documentation is updated; for impactful changes, information is added to the changelog for the intended release
  • CI is green

@GuySartorelli
Copy link
Member

The JS CI is failing as you haven't built the dist files. Can you please build that and include it in the PR?
Instructions are at https://docs.silverstripe.org/en/5/contributing/build_tooling/

@lekoala
Copy link
Contributor Author

lekoala commented Nov 27, 2024

from what i see in the tests, it's not my changes that creates error but i've compiled the files

on windows, it requires this to work
module.exports.rules['linebreak-style'] = ['error', 'windows'];

otherwise you get Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style

could be nice to add that as a default for https://github.com/silverstripe/eslint-config/blob/1/.eslintrc.js to make it windows friendly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants