Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Forms & Blueprints

Yet Another File Upload Thread

form

Solved by James Olewiler View solution

Started by James Olewiler 8 years ago · 1 replies · 822 views
8 years ago

New to Grav, but have looked through plenty of threads here regarding this issue. Hopefully someone will spot something and assist.

I have an application form that I need a file uploaded to. Upon submission of the form, I see the data file and get an email (has no reference to the file field) but there is no file in the specified directory. I can see the same results on my Mac and on my hosted web server. Permissions on the upload directory are 755. I've disabled almost all other site plugins to see if that helps, and I can confirm that PHP is allowing file_upload. Also changed the user/config/plugins/form.yaml values but can't confirm they are in use.

YAML
form:
  name: application-form
  classes: 'well'
  client_side_validation: false
  fields:

  - name: name
    label: Name
    classes: form-control
    outerclasses: form-group
    placeholder: John Johnson
    autofocus: on
    autocomplete: on
    type: text

  - custom_file: myfiles
    name: uploaded_files
    label: Uploaded Files
    type: file
    destination: 'user/data/files'
    outerclasses: form-group
    autofocus: false
    accept:
      - 'image/*'

process:
  - email:
    attachments:
      - uploaded_files

Thanks all.

8 years ago Solution

Oh man this took a good two days to figure out but I think I got it. The giveaway was that the Dropzone.js was throwing an error and not even rendering the form on the page. The problem was that the required Javascript was not being loaded.

I had this in my base template:

TWIG
{{ assets.js('bottom') }}

but I needed to add the other assets I referenced in the template so I change it to:

TWIG
{{ assets.js() }}

Problem with that was that it didn't load the Dropzone javascript, so doing this made it work:

TWIG
{{ assets.js() }}
{{ assets.js('bottom') }}

After adding this line, I was able to see the file upload form field and I could submit an entry that dumped the file into my specified location.
I hope this will help someone else having problems with the upload form.

👍 1

Suggested topics

Topic Participants Replies Views Activity
Forms & Blueprints · by Ton Haarmans, 5 years ago
13 1136 4 months ago
Forms & Blueprints · by Hugo Oliveira, 5 months ago
0 61 5 months ago
Forms & Blueprints · by Flachy Joe, 6 months ago
9 135 6 months ago
Forms & Blueprints · by Augustus, 7 months ago
7 110 7 months ago
Forms & Blueprints · by Julien, 7 months ago
10 129 7 months ago