如何上传文件以及如何下载 [英] How to Upload a file and how to download

查看:69
本文介绍了如何上传文件以及如何下载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何上传文件以及如何在c#中下载上传的文件,并且在上传过程中文件路径存储在MS Access中?

How to Upload file and also how to download uploaded file in c# and file path is stored in MS Access during uploading ?

推荐答案

您可以看到此
点击
you can see this
Click


protected void btnSub_Click(object sender, EventArgs e)
   {
       try
       {
           string filename = FileUpload1.FileName;

           FileUpload1.PostedFile.SaveAs(Server.MapPath("~\\Uploadform\\" + filename.Trim()));

           string path = "~\\Uploadform\\" + filename.Trim();

           OleDbConnection con = new OleDbConnection(str);//str is connection string
           cmd = new OleDbCommand("Insert into adminCircular(title,type,url1) values('" + txttitle.Text + "','" + txttype.Text + "','" + path + "')", con);
           lblinfo.Text = " Uploaded Successfully ";
           cmd.CommandType = CommandType.Text;
           con.Open();
           cmd.ExecuteNonQuery();
           con.Close();
       }
       catch (Exception ex)
       {
           Response.Write(ex.ToString());
       }
   }


这篇关于如何上传文件以及如何下载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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