0

Java コンソールで次のエラーが表示されます:「SyntaxError: unterminated regular expressionliteral」

私は本当にそれを理解していません。以下は私のコードです。誰かが私が欠けているものを指摘できれば、私は永遠に感謝します。

PHP コード:

print '
<script type="text/javascript">
function fakeUpload() {
    $("#fakeupload").val(this.files && this.files.length ? this.files[0].name : this.value.replace(/^C:\\fakepath\\/i, ""));
}
</script>';

ありがとう。

4

2 に答える 2

1

ここでエスケープスラッシュを逃しました

this.value.replace(/^C:\\fakepath\\//i, ""));
                                    ^

このようにしてみてください

<?php
print '
<script type="text/javascript">
function fakeUpload() {
    $("#fakeupload").val(this.files && this.files.length ? this.files[0].name : this.value.replace(/^C:\\fakepath\\//i, ""));
}
</script>';
于 2013-09-22T17:54:46.510 に答える