ASP.NET中上传头像的问题

来源:百度知道 编辑:UC知道 时间:2024/05/16 11:07:26
要让上传的图片并且立刻显示的代码什么?如下图
不行啊,出来的是个叉,我想要的效果是可以不用点击就可以看到我上传的图片,也就是实现一个暂时存储的功能,等我点击上传之后才真正确定上传,能实现么?

可以实现,用js就可以了,你搜一下js 上传预览就行了

<script language="javascript" type="text/javascript">
var flag=false;
function DrawImage(ImgD){
var image=new Image();
image.src=ImgD.src;
if(image.width>0 && image.height>0){
flag=true;
if(image.width/image.height>= 120/80){
if(image.width>120){
ImgD.width=120;
ImgD.height=(image.height*320)/image.width;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
ImgD.alt=image.width+"×"+image.height;
}
else{
if(image.height>80){
ImgD.height=80;
ImgD.width=(image.width*80)/image.height;
}else{
ImgD.width=image