本文介绍了如何在数据库中插入图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友,



请帮帮我,



如何在数据库中插入图片通过c#(上传文件),同时在重新启动它时应该显示在图片框中。



感谢你。

hello friends,

please help me out,

how to insert an image in database through c#(upload a file) and also while retriving it should display in picturebox.

thanking you.

推荐答案



protected void Button1_Click(object sender, EventArgs e)
       {
           if (FileUpload1.HasFile)
               try
               {
                   FileUpload1.SaveAs(Server.MapPath("~/your folder name/" + FileUpload1.FileName));
                   Label1.Text = "File name: " +
                        FileUpload1.PostedFile.FileName + "<br>" +
                        FileUpload1.PostedFile.ContentLength + " kb<br>" +
                        "Content type: " +
                        FileUpload1.PostedFile.ContentType;
                   filename.Text = FileUpload1.FileName;
               }
               catch (Exception ex)
               {
                   Label1.Text = "ERROR: " + ex.Message.ToString();
               }
           else
           {
               Label1.Text = "You have not specified a file.";
           }
       }


这篇关于如何在数据库中插入图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 18:57