Yet Another File Upload Thread

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.

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.

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:

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

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

{{ assets.js() }}

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

{{ 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 Like