Hi all-

Looking for a way to determine if a file exists before uploading.  I'm
working in asp.net and jquery, essentially my idea was to capture the submit
of the form, and .get the file name to another page that would return
true/false if the file existed.  If exists, confirm file overwrite, if not
just post it.

Problem is currently, it doesn't always catch that the file exists, and if I
do get the confirm it seems to be ignored and just posts anyhow.

Here's some of the code:

        <asp:FileUpload ID="FileUpload1" runat="server" />
        <asp:Button ID="Button1" runat="server" Text="Submit" />



        $(function(){
            $("#form1").submit(function() {
                return fileexists();
            });
        });

        function fileexists()
        {
            $.get("Exists.aspx", { file: $("#FileUpload1").val() },
function(data){
                if(data.toLowerCase() == "true")
                {
                    return confirm("Overwrite");
                }
                else
                {
                    return true;
                }
            });
        }



Any help is appreciated,
Pete

Reply via email to