I have a form, which includes a multiple file upload but when the form is submitted with the multiple upload empty I get a 500 error.
500 message “Repeater data is not an array or object”
How do I manage this form so that if the multi file upload is empty it does not throw an error?
I have a condition in server connect which checks value in the array and then initiates. It works when you have an image included but no images and throws a error. How can I make it ignore the multi image upload if it is empty?
That is strange, i can’t recreate this - even without a condition.
How is the POST variable for the upload input defined?
Also what’s the code for the upload input on the page?
<input id="media_feed_files" name="media_feed_files" type="file" class="form-control-file" multiple="true" is="dmx-dropzone" message="Drop image files here or click to upload." data-msg-accept="" dmx-bind:disabled="show_image_upload.value == 0" value="" data-rule-maxsize="5000000" data-msg-maxsize="Please select a file of no more than 5 Mb." accept=".png, .gif, .jpg">
I can’t manage to get this error with the dropzone component also.
Are you sure there is no other repeat in the server action causing this error? 500 message “Repeater data is not an array or object”
Well you can disable the repeater step and try outputting the expression used in the repeater in a setvalue step to see what does it return.
You can also check the headers / form data on the page (in dev tools) when submitting the form.
hi @Teodor I have done some testing and I think i know whey its rejecting at the repeat causing the 500.
On the first form submit it works on the second submit of the form it is adding “Null” to the form post for the dropzone file upload fields. I have captured the value in the SC side too and it is “Null” in the variable which is triggering the condition to think there is something there and is executing the rest of the SC when it shouldn’t - if the variable was empty.
Why would it do that and how do I make sure it does not?
I have tried clearing the form resetting the field on the first form success but still occurs.
The condition I have on the repeat in SC is simple $_POST.media_feed_files capturing the varibale value on the second form submit the variable is displaying as contain an actual value of "null"
This may not be the best solution but whenever I encountered this error to solve in my cases I added a condition before the repeat to check if the post var array isnt null then do the repeat