hi
i need multiple file fields for crud, i can easily do that, but every file should go to a different folder, there will be a folder for every record.
i couldn't managed to do this with grocery crud,
is there a way to do that ?
⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠
Posted 18 November 2015 - 15:38 PM
hi
i need multiple file fields for crud, i can easily do that, but every file should go to a different folder, there will be a folder for every record.
i couldn't managed to do this with grocery crud,
is there a way to do that ?
Posted 19 November 2015 - 01:12 AM
hi! imagine u have table posts and table post_imgs.
posts post_imgs
id id
filename
post_id
for every post record u write add_action function where u get and upload files per post_id
in that function u could choose how u implement filename per folder
option1 - when click add record with upload field per post_id just create record, folder with ID created record and redirect to
edit link of this record, this way u will have ID of record and can set in upload_path someting like UPLOAD_POST_IMGS_PATH.'/'.ID
option2 - same but when add file record per post u set upload path to some temp folder, and after u save record in callback_after_insert u create folder with inserted ID and move file from tmp folder to that created folder. in edit stay upload_path u will be already have. all states u can easily monitoring with GC. one gotchas here, in upload state u dont have primary_key of record so before it u can write ID in session
hope u understood:)