Gunakan variabel JS dalam aksi formulir

<script> var url = foo(); </script>

<form method="POST" action=""+url enctype="multipart/form-data">
NachooCh