Hi I'm uploading a file through an iframe.
HTML:
<from action="upload.php" target="iframe">
<input type="file" name="file" />
<input type="submit" />
</form>
<iframe name="iframe" src="javascript:false;"></iframe>
Now I would like to abort the upload while uploading. So I would like to stop the iframe loading.
What I've tried
$("iframe").attr("src", "javascript:false;");
$("iframe").remove();
if (typeof(window.frames[0].stop) === "function")
window.frames[0].stop();
else
window.frames[0].document.execCommand("Stop");
All functions don't throw an error but after a while the file I've canceled was displayed in the upload folder. So that's the weird thing.
Any suggestions?
While you can destory the iframe
element, any HTTP requests it has made cannot be cancelled. This is by design of HTTP.
The closest analogy is that it's like trying to stop a bullet you've fired by destroying the gun.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With