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

Grav frontend file uploading not working properly #550

Open
geogeorgejoseph opened this issue Jan 21, 2022 · 1 comment
Open

Grav frontend file uploading not working properly #550

geogeorgejoseph opened this issue Jan 21, 2022 · 1 comment

Comments

@geogeorgejoseph
Copy link

geogeorgejoseph commented Jan 21, 2022

Created a grav frontend form with file uploading feature. Except file upload everything working fine. When i trying to upload file, getting some errors from 'form.vendor.js' and file field seems to be empty after getting error. Errors given below

form.vendor.js:5 Uncaught TypeError: Cannot read properties of undefined (reading 'trim')
    at D.addedfile (form.vendor.js:5:11362)
    at D.value (form.vendor.js:5:1513)
    at D.value (form.vendor.js:5:25886)
    at HTMLInputElement.<anonymous> (form.vendor.js:5:17561)  

Form full definition given below

title: 'Job apply form'
published: true
body_classes: job-apply-main-page
cache_enable: false
visible: true
form:
    name: job-apply
    id: job-apply
    action: ' '
    fields:
        -
            name: job
            label: Job
            autocomplete: 'off'
            type: text
            validate:
                required: false
        -
            name: applicantName
            label: 'Name of Applicant *'
            autocomplete: 'off'
            type: text
            validate:
                required: true
                message: 'Please enter the applicant name'
        -
            name: email
            label: Email
            type: email
            validate:
                required: false
        -
            name: coverletter
            label: 'Cover Letter'
            type: textarea
            validate:
                required: false
        -
            name: resumefile
            label: Resume
            placeholder: 'Upload Resume'
            type: file
            destination: user/data/resume
            accept:
                - .pdf
                - .doc
                - .docx
            multiple: false
        -
            name: toEmail
            label: 'Hidden Field'
            type: text
            outerclasses: hide-input-field
            validate:
                required: false
        -
            name: enquiry-g-recaptcha-response
            label: Captcha
            type: captcha
            id: enquiry-captcha
            outerclasses: captcha-field
            recaptcha_not_validated: 'Captcha not valid!'
            validate:
                required: true
    buttons:
        -
            type: submit
            value: Save
    process:
        -
            email:
                subject: '{{form.value.hiddenField}}'
                from: '{{ config.plugins.email.from }}'
                to:
                    - test@gmail.com
                body: '{% include ''forms/data.html.twig'' %}'
                attachments:
                    - resumefile
        -
            email:
                subject: '{{form.value.hiddenField}}'
                from: '{{ config.plugins.email.from }}'
                to:
                    - '{{ form.value.email }}'
                body: '{% include ''forms/apply.html.twig'' with { "message": "Thank you for your Inquiry. We will get back you soon" } %}'
        -
            save:
                fileprefix: feedback-
                dateformat: Ymd-His-u
                extension: txt
                filename: site-enquire.txt
                operation: add
                body: '{% include ''forms/data.txt.twig'' %}'
                attachments:
                    - resumefile
        -
            message: 'Thank you for your feedback!'
            reset: true

Grav and other plugins updated to latest version

Grav v1.7.27.1
Admin v1.10.27
Form v5.1.4

@geogeorgejoseph geogeorgejoseph changed the title File uploading not working properly Grav frontend file uploading not working properly Jan 24, 2022
@michaelschoenbaechler
Copy link

michaelschoenbaechler commented Dec 30, 2022

Had a similar issue, was trying for hours. It worked for me when I removed "reset: true".
With "reset: true" the file was not saved at its destination.

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

No branches or pull requests

2 participants