使用asp.net或javascript上传图片? [英] upload images using asp.net or javascript?

查看:94
本文介绍了使用asp.net或javascript上传图片?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,

上传图片意味着:



在网页中包含:姓名,地址,mobileno,电子邮件,密码,确认密码,图片。



这里输入姓名,地址,mobileno,电子邮件,密码,确认密码



和目前我没有图像,下次上传图像选项后我想要。



这个可选的上传图片示例或逻辑请回复我

解决方案

这很简单

尝试这样的事情:

  if (Fileupload1.PostedFile.ContentLength!=  0 
{
// insert with image
}
else
{
// 无图像插入
}



和更新获取ID并上传

参考:文件上传控制 [ ^ ]


这是我的fileupload项目代码



试试吧.. :)



 protected void upload_Click(object sender,EventArgs e)
{
if(doctorfileupload.PostedFile!= null)
{
string FileName = Path.GetFileName(doctorfileupload.PostedFile 。文件名);
Session [filename] = FileName;
//doctorfileupload.SaveAs(Server.MapPath(\"~/images2/+ FileName));
string cont_name =;
cont_name = doctorfileupload.FileName;
string path = Server.MapPath(〜/ BenImages /);
doctorfileupload.SaveAs(path + cont_name);
string FullPath =〜/ BenImages /+ cont_name;
Session [pathname] = FullPath;
imagedisplay.ImageUrl = FullPath;
}
}


Dear All,
Upload images means:

in web page contain: name, address, mobileno,email,password, confirmpassword,image.

here once enter name, address, mobileno,email,password, confirmpassword

and currently i dont have image after next time upload image option i want.

this optional upload image examples or logic please reply me

解决方案

It's pretty simple
Try something like this:

if (Fileupload1.PostedFile.ContentLength != 0)
{
//insert with image
}
else
{
//insert without image
}


and for update get the ID and upload it


Refer: file-upload-control[^]


here is my fileupload project code

try it .. :)

protected void upload_Click(object sender, EventArgs e)
   {
       if (doctorfileupload.PostedFile != null)
       {
           string FileName = Path.GetFileName(doctorfileupload.PostedFile.FileName);
           Session["filename"] = FileName;
           //doctorfileupload.SaveAs(Server.MapPath("~/images2/" + FileName));
           string cont_name = "";
           cont_name = doctorfileupload.FileName;
           string path = Server.MapPath("~/BenImages/");
           doctorfileupload.SaveAs(path + cont_name);
           string FullPath = "~/BenImages/" + cont_name;
           Session["pathname"] = FullPath;
           imagedisplay.ImageUrl = FullPath;
       }
   }


这篇关于使用asp.net或javascript上传图片?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆