File upload without AJAX
I feel a bit like a party pooper with this, but I'm looking to create a form with a custom template that includes a simple file input. I don't really want to upload the file with AJAX, or use the custom dropzone design included in the default form template. It's nice functionality, but it seems targeted at a pretty specific use case, whereas I just want a click-to-submit form. From looking at 4f0d5b66166db79018ca16cdf07d8e83888d55ec, it seems like the form won't pick up any files from POST submissions anymore. Is that the case? Couldn't these two use cases coexist?
Closing because due to issue age. Please re-open if you continue to have issues
I also would like to know, if form submission would be possible without additional javascript. That'd be nice.
I think creating a simple field for file upload should work out of the box with the latest versions. Try it out and report a new bug if that doesn't work.
I tried the following without success (it requires javascript):
custom_file:
name: myfile
type: file
label: A Label
destination: 'user/data/uploads/myupload'
multiple: false
autofocus: false
accept:
- image/*
Could you please reopen the issue, as the name and description is exactly what the issue is about?
I meant you need to create your own file field type -- with plain old HTML file field. I think that should actually work as long as you define it properly.
Now I tried with:
custom_file:
name: myfile
type: simplefile
label: A Label
destination: 'user/data/uploads'
multiple: false
autofocus: false
accept:
- image/*
simplefile.html.twig
{% extends "forms/field.html.twig" %}
{% set defaults = config.plugins.form %}
{% set files = defaults.files|merge(field|default([])) %}
{% block input %}
<input
{# required attribute structures #}
{% block input_attributes %}
type="file"
{% if files.multiple %}multiple="multiple"{% endif %}
{% if files.accept %}accept="{{ files.accept|join(',') }}"{% endif %}
{% if field.disabled %}disabled="disabled"{% endif %}
{% if field.random_name %}random="true"{% endif %}
{% if required %}required="required"{% endif %}
{{ parent() }}
{% endblock %}
/>
{% endblock %}
Still not working. I tried to understand the code, but it seems to be split in many files with a lot of legacy stuff. Is the "legacy" upload the "normal" html upload you are referring to or is this "just" legacy code?
I want to note that I verified that file via ajax still works.