D
D
Doktorishka22018-09-05 10:43:30
JavaScript
Doktorishka2, 2018-09-05 10:43:30

The script does not work in Firefox, what is the reason?

Guys, I myself am not very savvy in JS, and even more so in regular expressions, but can someone tell me why the script, which works properly in all browsers, refuses to work in Mozilla?

$('#chooseFile').bind('change', function () {
        var filename = $("#chooseFile").val();
           if (/^\s*$/.test(filename)) {
            $(".file-upload").removeClass('active');
            $("#noFile").text("No file chosen..."); 
         }
         else {
            $(".file-upload").addClass('active');
            $("#noFile").text(filename.replace("C:\\fakepath\\", "")); 
         }
        });

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Proskurin, 2018-09-05
@Vlad_IT

Do not do this C:\\fakepath will be only on Windows, Linux, macos, mobile will have its own value. You can get the file name from Maybe for this reason it does not work in Firefox, I don’t remember exactly if the value is the same there or not.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question