我試圖從上傳輸入提醒文件名。使用jQuery與「拆分」報警輸入「文件」文件名
這裏是我的fiddle
它的工作原理,但有在 「C:Fakepath ......」 類似的東西。 我只想要文件名,沒有假路徑。我嘗試使用split
函數,但我不確定它爲什麼不起作用。
HTML示例:
<html>
<head>
<title>Test Page</title>
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
<input type="file" id="tester" />
</body>
</html>
示例腳本:
$(function() {
var bogus;
var triple;
$('#tester').change(function() {
triple = $('#tester').val();
bogus = triple.split(/[\s/]+/);
alert(bogus[bogus.length - 1]);
});
});
任何想法?
謝謝!
你就不能'$( '#測試')VAL()代替( 「C:\\ \\ fakepath」, 「」)'? – 2012-08-10 15:43:45