asp.net(fileupload)上传图片预览
2010/12/28 8:16:14 lingxiao200 http://lingxiao200.javaeye.com
我要评论(0)
- 摘要:<scriptlanguage="javascript">function$(o){returndocument.getElementById(o);}functionCheckImgCss(o,img){if(!/\.((jpg)|(bmp)|(gif)|(png))$/ig.test(o.value)){alert('只能上传jpg,bmp,gif,png格式图片!');o.outerHTML=o.outerHTML;}else{$(img).filters.item
- 标签:.net ASP.NET file 图片 上传 net
<script?language="javascript">
function?$(o){return?document.getElementById(o);}
function?CheckImgCss(o,img)
{
????if?(!/\.((jpg)|(bmp)|(gif)|(png))$/ig.test(o.value))
????{
????????alert('只能上传jpg,bmp,gif,png格式图片!');
????????o.outerHTML?=?o.outerHTML;
????}
????else
????{
????????$(img).filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src=o.value;
????????//$('Image1').src?=?o.value;//这里IE7已经不支持了。所以才有上面的方法。
????}
}
</script>
????<form?id="form1"?runat="server">
????<div><h1>一次上传多个图片并预览,请选择图片:</h1>
????????<asp:FileUpload?ID="FileUpload1"?onchange="CheckImgCss(this,?'img');"?runat="server"?/>
????????<asp:FileUpload?ID="FileUpload2"?onchange="CheckImgCss(this,?'img');"?runat="server"?/>
????????<asp:Button?ID="Button1"?runat="server"?OnClick="Button1_Click"?Text="上传"?/>
????????<div?id="img"?style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=<%=?pic%>,sizingMethod=scale);width:102px;height:100px;"></div>
????????</div>