如何获取input type=file的路径
展开全部
1.IE内核的部分,IE10 没问题,别的没试,
[html] view plain copy
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript" src="软件工程概论/软件工程实验原型/js/jquery-1.8.3.min.js"></script>
<script type="text/javascript">
var imgurl = "";
function getImgURL(node) {
var imgURL = "";
var file = null;
if(node.files && node.files[0] ){
file = node.files[0];
}else if(node.files && node.files.item(0)) {
file = node.files.item(0);
}
//这种获取方式支持IE10
node.select();
imgURL = document.selection.createRange().text;
alert(imgURL);
var textHtml = "<img src='"+imgURL+"'/>"; //创建img标签用于显示图片
alert(textHtml);
$(".mark").after(textHtml);
return imgURL;
}
[html] view plain copy
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript" src="软件工程概论/软件工程实验原型/js/jquery-1.8.3.min.js"></script>
<script type="text/javascript">
var imgurl = "";
function getImgURL(node) {
var imgURL = "";
var file = null;
if(node.files && node.files[0] ){
file = node.files[0];
}else if(node.files && node.files.item(0)) {
file = node.files.item(0);
}
//这种获取方式支持IE10
node.select();
imgURL = document.selection.createRange().text;
alert(imgURL);
var textHtml = "<img src='"+imgURL+"'/>"; //创建img标签用于显示图片
alert(textHtml);
$(".mark").after(textHtml);
return imgURL;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询