RSS Feed

Posts Tagged ‘c:fakepath’

  1. C Fakepath fix

    September 1, 2011 by Dave

    So I’m sure any developers reading this have come across the Safari, IE7+ and Opera issue where an upload field is for whatever reason filled with C:\fakepath\filename GRR! How annoying!

    But below is a really simple fix!

        //get our form field
        var a = document.getElementById('myUploadField'),
            b = encodeURI(a.value),
            c = b.replace("C:%5Cfakepath%5C","");
        //We then listen for the value changing and
        //remove the C:\fakepath\ from it! easy!
        a.onchange = function () {
            this.value = c;
        }
    

    How easy was that!