500 error when multiple file upload is submitted empty?

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?

What have you selected in the upload step expression field?

@Teodor this?

Also when I hard refresh the page and submit the form the first time with no images it works.

But then if you submit the form again on the second submit or any subsequent times it gives me the 500.

I have on first success set the form success to reset the form and even tried to reset the multi upload field thinking that may fix it but doesn’t.

Could it be holding something after the first submit.

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?

The page input code:

<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">


Ah so you are using the dropzone component, not an upload input? Let me test this.

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”

I can do some more testing tomorrow but it works when I remove this input field. There isn’t any other repeat in SC.

Is there a way I can see what is being returned other than the 500 add some tracking to try and capture more detail?

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.

Ok thanks will try this out tomorrow try and find out what’s going on and why it only happens at the second form submit.

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

How did you do this?

is it as simple as condition: variable != “null” ?


Yeah that’s all I was doing on the variable and then have the repeat in the ‘then’ part of the condition

Also I didn’t add the quotes around null but could try both your case might be slightly different

Thanks. Is this a bug or is it supposed to behave like this?

It should not behave like that. Could you test if the following update fixes your issue.

dmxDropzone.zip (3.3 KB)

1 Like

Hi @patrick just caught me, and YES we have lift off - the issue is no longer - Fixed.

Fixed in Wappler 4.2.0