fakepath 解决上传图片,文件时候的路径替换问题
<script type="text/javascript">
function getPath(obj) {
?if (obj) {
??if (window.navigator.userAgent.indexOf("MSIE") >= 1) {
???obj.select();
???return document.selection.createRange().text;
??}
??else if (window.navigator.userAgent.indexOf("Firefox") >= 1) {
???if (obj.files) {
????return obj.files.item(0).getAsDataURL();
???}
???return obj.value;
??}
??return obj.value;
?}
}?
//以下即为完整客户端路径
var filepath=getPath(document.getElementById("iptfileupload"));
</script>