本文主要是介绍火狐IE下获取完整文件路径名的方法,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
抄:
以下为引用的内容: |
<input name="upfile1" type="file" id="upfile1" οnchange="SeePicNew2('uploadfield1',this);" />
<div class="divpre" id='uploadfield1'></div>
function SeePicNew2(imgdid,f) {
if(f.value=='') return ;
var newPreview = document.getElementById(imgdid);
// 这段代码是关键,如果是FF,则f.fles为真
if (f.files) {
var filepath = f.files.item(0).getAsDataURL();
} else {
var filepath = 'file:///'+f.value.replace(g,"/").replace(//:/,"|");
}
var image = new Image(); var ImgD = new Image();
ImgD.src = filepath;
image.src = ImgD.src; FitWidth = 150; FitHeight = 100;
if(image.width>0 && image.height>0)
{
if(image.width/image.height>= FitWidth/FitHeight)
{
if(image.width>FitWidth)
{
ImgD.width=FitWidth;
ImgD.height=(image.height*FitWidth)/image.width;
}
else
{
ImgD.width=image.width;
ImgD.height=image.height;
}
}
else
{
if(image.height>FitHeight)
{
ImgD.height=FitHeight;
ImgD.width=(image.width*FitHeight)/image.height;
}
else
{
ImgD.width=image.width;
ImgD.height=image.height;
}
}
}
newPreview.style.width = ImgD.width+"px";
newPreview.style.height = ImgD.height+"px";
if(window.navigator.userAgent.indexOf("MSIE") < 1)
{
newPreview.style.background = "url('"+ImgD.src+"') no-repeat";
}
else
{
newPreview.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ImgD.src+"',sizingMethod='scale')";
}
ImgD = image = null;
//newPreview.filters.item('DXImageTransform.Microsoft.AlphaImageLoader').src = f.value;
}
这篇关于火狐IE下获取完整文件路径名的方法的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!