将图像控制中的图像保存到服务器 [英] Save image from image control to server

查看:96
本文介绍了将图像控制中的图像保存到服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hii



我的页面上有asp.net图像控件。我想从服务器上的图像控制中保存图像。

我已经看过

将图像保存到asp文件夹中:图像控件 [ ^ ]







http://stackoverflow.com/questions/8374284/save-image-from-image-control-to-website-directory [ ^ ]



这个链接的问题是它没有从ImageControl(asp:Image)读取,我必须从ImageControl读取它,因为我的图像源来自jquery而不是来自asp.net代码,我不想使用jquery作为我想要做 使用asp.net进行更多图像处理。



提前谢谢

Hii

I have asp.net image control on my page. I want to save image from image control on server.
I have already seen
Save image to a folder from an asp:Image control[^]

and

http://stackoverflow.com/questions/8374284/save-image-from-image-control-to-website-directory[^]

problem with this link is its not reading from ImageControl(asp:Image), i have to read it from ImageControl, because my image source is coming from jquery not from asp.net code, and i dont want to use jquery as i want to do some more image processing using asp.net.

Thanks in advance

推荐答案

看看这个

http://forums.asp.net/t/1812618.aspx/1 [ ^ ]


试试这个,我希望它可以帮到你

Try this, I hope it may help you
protected void btnUpload_Click(object sender, EventArgs e)
{
      string filename;
      string ImageFileName;
      if (pics.HasFile)
      {
          filename = System.IO.Path.GetFileName(pics.FileName);
          pics.SaveAs(Server.MapPath("/Galery/") + filename);
          ImageFileName = "/Galery/" + filename;
      }
      
      SqlConnection Conn = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["myConnectionString"]);
      SqlCommand CatCmd = Conn.CreateCommand();
      Conn.Open();
      
      try
      {               
          CatCmd.CommandText = "insert into PhotoGaleryImage(CatagoryId,Path,UserId) values('CatagoryID','ImageFileName','userId')";
                
          CatCmd.ExecuteNonQuery();
      }
      catch (Exception) { }
      finally
      {
          if (Conn != null && Conn.State == ConnectionState.Open)
          {
              Conn.Close();
              Conn.Dispose();
          }
      }      
}



* Galary应该是解决方案中包含的文件夹之一

* pics是Fileupload控件



继续微笑:) :) :)快乐编码:)


这篇关于将图像控制中的图像保存到服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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