Click here to Skip to main content
15,891,902 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
//The thing is like :
// In chrome : First I click browse and select a file, then again, if I click browse and then
// cancel, the file uploader get cleared. (but that doesn't happen in IE)

// for that, I need to know, which button (OK / Cancel) is being pressed in the file upload
// dialog box

//Here's my JS

JavaScript
<script type="text/javascript">
    
    function clear() {
        if ($.browser.msie) {
            
            //To clear the file uploader

            var who = document.getElementsByName('<%= fileID.UniqueID %>')[0];
            who.value = "";
            var who2 = who.cloneNode(false);
            who2.onchange = who.onchange;
            who.parentNode.replaceChild(who2, who);

            //=========
        }
    }

</script>



// Html


ASP.NET
<div id="upload-area">
                                <asp:FileUpload ID="fileID" runat="server" Width="427px" onclick="clear()"/>                               
                                
                            </div>
Posted
Updated 18-Aug-14 23:20pm
v2

Hi Kingshuk,

Quote:
I need to know, which button (OK / Cancel) is being pressed in the file upload
You can't do it directly. As file dialog is not exposed to the browser.

I have searched for this and got a different approach to it. Here it is not direct, but in this way you can get your solution.

Link - http://jsfiddle.net/Shiboe/yuK3r/6/[^]
 
Share this answer
 
v2
I also got this, but its not the way I need.. 😊
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900