Skip to content

File uploading though scripts in pb_hooks folder #4956

Closed Answered by ganigeorgiev
alwaysq asked this question in Q&A
Discussion options

You must be logged in to vote

I'm having difficulties understanding the above code and what actually it is its purpose or its desired behavior (c.request().formFile("") doesn't make sense; also there is no need for async in the hook handler).

Note that you don't need to manually call form.loadData and form.addFiles if you use form.loadRequest. form.loadRequest takes care for loading all request fields (both regular data and files) into the form and its related record (as long as the submitted request field names match with the collection schema). Or in other words, your route could be simply:

routerAdd("POST", "/accTrans", (c) => {
    const collection = $app.dao().findCollectionByNameOrId("accTrans");
    const record =

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@alwaysq
Comment options

Answer selected by alwaysq
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants