Hi, i want to know how i can cancel a file upload with a form multipart/form-data. Is that possible ?
Make the form post to a hidden iframe, change the iframe src
when you wanna cancel, the browser will reload the iframe and cancel the previous POST
request on it.
The upload is a user's browser POSTing the data up to the server. You'll need to cancel it on the user-side. Unfortunately, JS is single-threaded (usually) so it's hard to interrupt it.
You can use JavaScript to change the upload URL (to nothing, LocalHost, etc) if you first have the upload pointed to an iFrame. You can change the iFrame SRC mid-stream. You can also refresh the page or take the user to a new page from the iFrame back to the parent.
These iFrame tricks are ways to 'interrupt the upload on the main page'.
You can also provide cancel buttons that should capture user events (clicks) that change the URL of the page