Hello,
I’ve modified user form (frontend) user_profile to add file field upload. Everything is working great. File is saved in folder. But I can’t delete that added file by user_profile form. Am I doing something wrong or form plugin can’t do that?
GetGrav # v1.7.24
form plugin # v5.1.3
login pugin # v3.6.0
user\plugins\login\pages\profile.md:
custom_file:
type: file
label: A Label
multiple: false
destination: 'page@:/test'
random_name: false
avoid_overwriting: true
limit: 10
accept:
- image/*
user\config\plugins\login.yaml:
fields:
- custom_file
user\accounts\user.yaml:
custom_file:
‘user/pages/test/myfile.jpg’:
name: myfile.jpg’
type: image/jpeg
size: 33461
path: ‘user/pages/test/myfile.jpg’
@tomasz_s1,
Please note:
- Don’t ever change file below
/user/plugins/*
or /user/themes/*
. Any changes made to plugin/theme files will be removed after an update of plugin/theme.
- According the docs:
The file
field is intended to be used by configuration , theme , and plugins blueprints, NOT page blueprints . For pages, you should use the existing pagemedia
field and then utilize the filepicker field to select the files.
Answer:
AFAIK (and Grav has more secrets I don’t know off), the forms plugin does not provide an option to delete uploaded files.
Possible solution:
- Create a plugin that handles event
onFormProcessed
. You will then have the ability to add your own logic.
I would like to let users add their own file only to read/delete by the owner of this file (that user). Destination of saving file is not important.
Do I have to write my plugin or is any GetGrav plugin? What is best solution to do it?
@tomasz_s1, You will have to write you’re own custom plugin to handle the onFormProcessed
event. Unless you can find one on the plugin repository that suits your needs (but I doubt you will).