Dynamic Upload path error

trying to make a dynamic path when uploading af file with the following as path:

/users/{{$_GET.uid}}/company/logo

{{$_GET.uid}} is session id on the company, so the file gets uploaded in the right companys folder.

The path gets created and the file uploaded in: users/company/logo, so it ignores the {{$_GET.uid}}

What am I doing wrong ??

Hi, where is the {{$_GET.uid}} coming from? You can’t use GET variables when submitting a form, which uses a POST method.

I`m having the uid as a session variable in the Session Storage Manager…

You can’t use GET like that. In your case you need to create a hidden input in the form and bind the session value to it. Then use the {{$_POST.hidden_field}} in the dynamic path.

Okay I will try that…

Thanks Teodor… worked perfectly…

@Teodor
It works perfect as long as I upload an image. But if I dont want to add an image and press “next”
I get an error.
When I try to look at the error in firefox developertools I get this:

SyntaxError: JSON.parse: unexpected non-whitespace character after JSON data at line 1 column 1039 of the JSON data

Can you help !
Best regards

Well if you don’t select an image the upload step receives a null value, which causes the error.
Just wrap your upload step in a condition and just use {{$_POST.your_input_here}} as an expression. If the input has a value (file is selected) the upload placed in the then step will run, else it won’t.

Okay I will try. Does I create this expression in the page with the form or in the server action file ?

You add the condition in the server action steps … that is where your upload step is located.

1 Like

Cant seem to find a validation condition there will fit, if a fom field is empty or not.
What validation rule should be used for this ??

You do not add validation. Just add a Condition step and select your post variable as an expression, that’s all.