火狐IE下获取完整文件路径名的方法
2010-05-20 21:11
351 查看
抄:
<input name="upfile1" type="file" id="upfile1" onchange="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;
}
以下为引用的内容: |
<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;
}
相关文章推荐
- 批处理(bat)实现全盘搜索指定文件获取其完整路径方法大全
- 批处理集锦——(6)【转】批处理实现全盘搜索指定文件获取其完整路径方法大全
- (转)批处理(bat)全盘搜索指定文件获取其完整路径方法大全
- 上传时获取文件的完整路径图片预览的js代码(兼容Firfox和IE)
- 批处理(bat)实现全盘搜索指定文件获取其完整路径方法大全
- js 文件路径的获取,包括火狐,IE
- IE,FF获取文件绝对路径方法
- iOS 获取文件的目录路径的几种方法
- 文件、文件路径(path)详解及文件夹下所有文件获取方法介绍
- python获取指定路径下所有指定后缀文件的方法
- vs 获取当前程序文件的路径方法
- java路径以及获取资源文件的方法
- iOS中获取各种文件的目录路径的方法
- phpcms v9多文件上传字段获取文件url路径地址的方法
- IOS中获取各种文件的目录路径的方法
- Liferay Dynamic CSS Filter方法的研究 - 从请求文件URI到获取资源文件真实路径
- 【IOS功能实现】之 获取各种文件的目录路径的方法
- 获取文件路径的方法
- java读取properties文件,获取路径的方法
- IOS中获取各个文件的目录路径的方法和NSFileManager类