The for each statement is excepting an array to be defined in the trigger body. The likely hood is that you are referencing the entire JSON object from the trigger body with the dynamic value 'triggerBody()'. Chances are if you are wanting to loop through multiple objects within the trigger, then you'd need to reference it like 'triggerBody().AnArray'. The below examples show the syntax in JSON of an object, wrapped with braces "{ }" and arrays, with square brackets "[ ]".
"body :{
"AnArray: ["A","B",C"]
}
If there isn't multiple objects, then simple do not use the foreach loop. If this still doesn't make sense, share the output of the trigger "when a file is created or modified in a folder".
kind regards
Alistair