【发布时间】:2011-09-03 13:21:58
【问题描述】:
当input field的change event发生时,我尝试获取上传值
但我在 Chrome 上得到了这个值,
C:\fakepath\winnie-the-pooh.jpg
所以我将\ 和数组中的最后一项分开。
jquery,
$("#upload").change(function(){
var fragment = $("#upload").val();
var array_fragment = fragment.split('\/');
alert($(array_fragment).last()[0]);
});
但我在 Chrome 上仍然得到 C:\fakepath\winnie-the-pooh.jpg 而不是 winnie-the-pooh.jpg。
我怎样才能让它发挥作用?
html,
<input type="file" name="image" id="upload"/>
【问题讨论】:
-
无法在 chrome 中获取完整路径。 stackoverflow.com/questions/4851595/…
标签: jquery google-chrome file-upload onchange