These forums are read-only and considered to be an archive. Please use the new Community for future interaction and posts.

OverWrite Prompt

Has Anyone figured out yet how to prompt for an overwrite if file names match when uploading files? I have been able to get the logic to work, as you can see i created a fake var just to trigger a confirm ( if (x == 1) ). 

I can't seem to figure out what to replace( if (x == 1) ) to ( if (existing file name = the uploading file name).

function Upload() {
        var x = 1;
        if (x == 1) {
            var y = confirm("OverWrite File");
                if (y == true) {
                document.forms.formBuffer.submit();
                } else {
                alert("Upload Aborted");
                close();   
                }
        } else {
            document.forms.formBuffer.submit();
        }
    }
Mark 12/8/2011 11:06 AM
I am now able to get the uploading document name, and parse the extention that will be in the file(uploading inputbox) to look like test.txt instead of the full path ( example C:\documents\someFolder\test.txt ) and if i hard code a name to compare it with i see results. 

But now i need to try to get the server side file name to compare with my uploading document name. Anyone know i can get this name? I trying to figure different ways in using php, VBscript or asp and then somehow try to call a function or variable in javascript or call javascript in The VBscript stuff.

Any help would be most appreciated.


(heres what i got so far) 
function Upload() {

        var x = document.getElementById("file").value.replace(/^.*[\\\/]/, '');  // parse file to only show test.txt
        if (x == ("test.txt")) {
            var y = confirm("OverWrite File ?");
            if (y == true) {
                document.forms.formBuffer.submit();
            } else {
                alert("Upload Aborted");
                close();
            }
        } else {
        document.forms.formBuffer.submit();
        close();
        }
    }     
Mark 12/12/2011 1:24 PM
ya scratch all that, it seems i was modifying the wrong file. I have to modify the Public Function Upload() in wexGeneric.asp file. This way i can verfiy if file exists by "If FSO.FileExists(FSO.BuildPath(path, uploadedFileName))"

seems than i can add "Response.Write("<script>javascript: confirmation();</script>")", to call a js function where i call a confirm box "if (confirm("OverWrite File?") == true)", but now i need to find a way to send back to server side. 

I need to either try to implement ajax or something to either re-submit the form or cancel the upload process and close the stream.....Stuck on this part now
Mark 12/16/2011 6:57 AM