I'm putting together a small HTML page that allows the user to upload files from his local device to the server. I'm using an approach that I found recommended in several places, which goes like this:
<FORM method="post" action="upload.py" enctype="multipart/form-data">
<INPUT type="file" name="rhythm-file">
<INPUT type="submit">
</FORM>
This works, but it takes the user away from the page to upload.py
. How can I stay on the page? I tried using action="upload()"
to call a JavaScript function, with the idea of calling an asynchronous HTTP request from there, but then the browser tries to navigate to cgi-bin/upload()
. I also considered modifying upload.py
to redirect back to the previous page, but that just doesn't feel like the correct way to do it.