Question
Could you please advise, there is a need to upload one or more files into a temporary table (form) with subsequent insertion into a simple table, each in a separate row. I tried doing it like this:
Button action code in the temporary table, which should write files into the Simple:
=: listReplace(list: #h_file_field; action: $val; value: "value")
val: insert(table: 'simple_table'; field: 'file_field' = $filesdata)
filesdata: listCreate(item: $rowfile)
rowfile: rowCreate(field: "name" = $#value[name]; field: "filestring" = $#value[filestring])
But this code does not work.
Answer
In the provided example, there is a lack of obtaining the file content, which is passed to filestring
. In it, $#value[filestring]
is passed to filestring
, while in the File field structure there is no filestring
key, but there is a file
key that contains the file name on the server. That is, you need to get the file content using this file
key.
Button action code:
=: listReplace(list: #h_file_field; action: $val; value: "value")
val: insert(table: 'simple_table'; field: 'file_field' = $filesdata)
filesdata: listCreate(item: $rowfile)
rowfile: rowCreate(field: "name" = $#value[name]; field: "filestring" = $content)
content: fileGetContent(file: $#value[file])
The fileGetContent
function retrieves the file content ā text or binary, as it is stored in the file system.