【问题标题】:How to save Image Control Image in Folder in Asp.net如何在 Asp.net 的文件夹中保存图像控制图像
【发布时间】:2012-05-22 05:30:31
【问题描述】:

我知道如何使用 fileupload 控件和 saveas 方法将图像保存到文件夹。但是我从图像控件中获取图像并将其保存到文件中而不使用文件上传控件 n 将其保存在文件夹中。

【问题讨论】:

    标签: c# asp.net sql


    【解决方案1】:
    string filepath = img1.ImageUrl;           
    using (WebClient client = new WebClient())
    {
           client.DownloadFile(filepath,Server.MapPath("~/Image/apple.jpg"));
    }
    

    【讨论】:

      【解决方案2】:

      你知道图片路径吗?您可以从图像控件中获取图像路径,然后在代码中下载图像:

      Download image from the site in .NET/C#

      using(WebClient client = new WebClient()) 
      {
          client.DownloadFile("http://www.example.com/image.jpg", localFilename); 
      } 
      

      【讨论】:

        【解决方案3】:

        首先获取图片的Url,然后使用webclient可以将文件保存到文件夹中

        string filepath = img1.ImageUrl;           
        using (WebClient client = new WebClient())
        {
               client.DownloadFile(filepath,Server.MapPath("~/Image/apple.jpg"));
        }
        

        这将使用 ImageName apple 将图像保存在图像文件夹中...

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2019-09-21
          • 2018-05-26
          • 2019-04-10
          • 2022-01-12
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多