Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to cancel file upload that uses hidden iframe?

Is it possible to cancel file upload that uses hidden iframe?

I've tried to set source of iframe to empty string, but upload haven't been interrupted.

like image 861
Alexey Zakharov Avatar asked Mar 12 '11 05:03

Alexey Zakharov


3 Answers

the iframe is the transport channel that is carrying the form posting, so Atanas is correct, you have to stop the transport inside the iframe.

here is a way of doing it depending on browser:

if (iframeObj.contentWindow.document.execCommand)
    { // IE browsers
        iframeObj.contentWindow.document.execCommand('Stop');
    }
else
    { // other browsers
        iframeObj.contentWindow.stop();
    }
// notify user upload was cancelled, remove spinner images, etc
like image 143
Steve Wasiura Avatar answered Oct 06 '22 01:10

Steve Wasiura


Try this:

iframe.contentWindow.stop(); //for anything but IE
iframe.contentWindow.document.execCommand("Stop"); // for IE
like image 39
Atanas Korchev Avatar answered Oct 06 '22 01:10

Atanas Korchev


Currenty setting iframe src to "javascript:false" works for me.

like image 20
Alexey Zakharov Avatar answered Oct 06 '22 00:10

Alexey Zakharov