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

圖片上傳即時(shí)顯示縮略圖的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技術(shù)圖片上傳即時(shí)顯示縮略圖的js代碼,轉(zhuǎn)載需保留來源!

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請(qǐng)第一時(shí)間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 新竹市| 长寿区| 讷河市| 呼玛县| 杭州市| 汉源县| 泗阳县| 天祝| 林周县| 城步| 城固县| 屏东市| 江达县| 尼玛县| 通州市| 汉源县| 开化县| 修武县| 枞阳县| 奎屯市| 凭祥市| 西乌珠穆沁旗| 宣汉县| 轮台县| 晋江市| 合川市| 什邡市| 大姚县| 马山县| 辰溪县| 聂拉木县| 宿州市| 肇源县| 金山区| 伽师县| 庆安县| 南华县| 秦安县| 广宁县| 和平区| 云梦县|