1

I have a simple form with a file upload field in built with the latest version of Craft 3 and Freeform and I haven't been able to get the file upload to the field to work. When you submit the form with all fields completed and a file selected, you get a submission error saying "Error! Please review the form and try submitting again". Here is my template code, any idea what's wrong?

{# -- Freeform Form --#}
{% set form = craft.freeform.form("contact") %}

{{ form.renderTag({returnUrl: "/contact/thanks"}) }}    

{% if form.hasErrors %}
    <div class="freeform-form-has-errors">
        <strong style="color:red;">{{ "Error! Please review the form and try submitting again."|t('freeform') }}</strong>
    </div>
{% endif %}

{% set fullName = form.get("fullName") %}
{% set emailAddress = form.get("emailAddress") %}
{% set phone = form.get("phone") %}
{% set resume = form.get("resume") %}

<p>
    <input type="text" name="{{ fullName.handle }}" id="{{ fullName.value }}" placeholder="Full Name*" autocomplete="off" class="text"/>
    <i style="color:red;">{{ fullName.renderErrors() }}</i>
</p>

<p>
    <input type="email" name="{{ emailAddress.handle }}" id="{{ emailAddress.handle }}" placeholder="Email Address*" autocomplete="off" class="text">
    <i style="color:red;">{{ form.get("emailAddress").renderErrors() }}</i>
</p>

<p>
    <input type="text" name="{{ phone.handle }}" id="{{ phone.handle }}" placeholder="Phone" autocomplete="off" class="text">

    {% if form.get("phone").hasErrors %}<i style="color:red;">This field is required!</i>{% endif %}
</p>

<div class="heading">
    <label class="required" for="resume">Attachment</label>
</div>

<p>
    <label for="resume" class="leave"><i class="fa fa-paperclip" aria-hidden="true"></i> Attach Resume *</label>
    <input type="file" class="form-control-file" name="resume[]" id="resume"/>
</p>

<p class="required-wrap">
    <em class="required">* Required</em>
    <button type="submit" class="button">Send</button>
</p>
{{ form.renderClosingTag }}

{# -- End Freeform Form --#}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.