色尼玛亚洲综合影院,亚洲3atv精品一区二区三区,麻豆freexxxx性91精品,欧美在线91

圖片上傳即時顯示縮略圖的js代碼

<script language="Javascript" type="text/Javascript">
var allowExt = ['jpg', 'gif', 'bmp', 'png', 'jpeg'];
var preivew = function(file, container){
try{
var pic = new Picture(file, container);
}catch(e){
alert(e);
}
}
//縮略圖類定義
var Picture = function(file, container){
var height = 0,
widht = 0,
ext = '',
size = 0,
name = '',
path = '';
var self = this;
if(file){
name = file.value;
if (window.navigator.userAgent.indexOf("MSIE")>=1){
file.select();
path = document.selection.createRange().text;
}else if(window.navigator.userAgent.indexOf("Firefox")>=1){
if(file.files){
path = file.files.item(0).getAsDataURL();
}else{
path = file.value;
}
}
}else{
throw "bad file";
}


ext = name.substr(name.lastIndexOf("."), name.length);

if(container.tagName.toLowerCase() != 'img'){
throw "container is not a valid img label";
container.visibility = 'hidden';
}
container.src = path;
container.alt = name;
container.style.visibility = 'visible';
height = container.height;
widht = container.widht;
size = container.fileSize;


this.get = function(name){
return self[name];
}

this.isValid = function(){
if(allowExt.indexOf(self.ext) !== -1){
throw 'the ext is not allowed to upload';
return false;
}
}
}
</script>
<div class='previewDemo'>
<input id="file" type="file" onchange="preivew(this, document.getElementById('img'));">
<img id="img" style="visibility:hidden" height="100px" width="100px">
</div>

JavaScript技術圖片上傳即時顯示縮略圖的js代碼,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 万源市| 株洲市| 绥中县| 个旧市| 邓州市| 萝北县| 西青区| 五莲县| 沂南县| 岳普湖县| 唐河县| 剑河县| 正宁县| 苍山县| 南涧| 武陟县| 洞头县| 格尔木市| 霞浦县| 玛曲县| 颍上县| 江达县| 佛冈县| 资阳市| 武强县| 青海省| 兴宁市| 澄城县| 定西市| 镇巴县| 永修县| 通州市| 噶尔县| 延吉市| 四子王旗| 青龙| 庆云县| 军事| 新建县| 巨野县| 鱼台县|