Użyj zmiennej JS w formie akcji
<script> var url = foo(); </script>
<form method="POST" action=""+url enctype="multipart/form-data">
NachooCh
<script> var url = foo(); </script>
<form method="POST" action=""+url enctype="multipart/form-data">