经观察 qq空间 等上传图片的预览 都是先将图片上传到服务器,然后在通过远程图片url进行本地阅览。

 

思路:对于支持 window.url 的浏览器 使用 url= window.url.createObjectURL(file); img.src = url;

不支持window.url 的ie 使用:div.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod='image',src='"+完整文件名+"')"

栗子:

fileInput.onchange = function(e)
{
this.select();
var nfile = document.selection.createRange().text;
alert("当前选择的文件完整路径是:"+nfile);
document.selection.empty(); document.getElementById("tp").style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod='image',src='"+nfile+"')";
}

 

以上两种都不支持,先将图片 传到服务器 再进行 预览.

 

相关文章:

  • 2021-10-29
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-16
  • 2022-12-23
  • 2021-12-09
猜你喜欢
  • 2021-07-31
  • 2022-12-23
  • 2021-08-11
  • 2022-12-23
  • 2022-12-23
  • 2021-09-09
相关资源
相似解决方案