请问点聚weboffice能够实现将编辑文件保存到服务器吗? 10
1个回答
展开全部
public partial class upload : System.Web.UI.Page
{
SqlCommand cmd;
SqlConnection cn;
string docTitle, docType;
protected void Page_Load(object sender, EventArgs e)
{
Response.Clear();
string id = Request.Params["DocID"];
docTitle = Request .Params["DocTitle"];
docType =Request .Params ["DocType"];
if (docType == "")
docType = "doc";
if (Request.Files.Count > 0)
{
HttpPostedFile file = Request.Files[0];
int fileLength = file.ContentLength;
byte[] photoArray = new Byte[fileLength];
Stream photoStream = file.InputStream;
photoStream.Read(photoArray, 0, fileLength);
string strcn = ConfigurationManager.ConnectionStrings["WebOffice"].ConnectionString;
cn = new SqlConnection(strcn);
cn.Open();
string sql;
if (!String.IsNullOrEmpty(id))
{
sql = "update WebDoc Set DocContent=@DocContent where DocID=@ID";
cmd = new SqlCommand(sql, cn);
cmd.Parameters.Add("@ID",SqlDbType.Int).Value =id;
cmd.Parameters.Add("@DocContent", SqlDbType.Binary).Value = photoArray;
cmd.ExecuteNonQuery();
}
else
{
sql = "Insert into WebDoc(DocTitle,DocType,DocContent) values(@DocTitle,@DocType,@DocContent)";
cmd =new SqlCommand(sql,cn);
cmd.Parameters.Add("@DocTitle", SqlDbType.VarChar, 50).Value = docTitle;
cmd.Parameters.Add("@DocType", SqlDbType.VarChar, 10).Value = docType;
cmd.Parameters.Add("@DocContent", SqlDbType.Binary).Value = photoArray;
cmd.ExecuteNonQuery();
}
cn.Close();
Response.Write("succeed");
Response .End();
}
else
Response.Write("fail");
}
}
{
SqlCommand cmd;
SqlConnection cn;
string docTitle, docType;
protected void Page_Load(object sender, EventArgs e)
{
Response.Clear();
string id = Request.Params["DocID"];
docTitle = Request .Params["DocTitle"];
docType =Request .Params ["DocType"];
if (docType == "")
docType = "doc";
if (Request.Files.Count > 0)
{
HttpPostedFile file = Request.Files[0];
int fileLength = file.ContentLength;
byte[] photoArray = new Byte[fileLength];
Stream photoStream = file.InputStream;
photoStream.Read(photoArray, 0, fileLength);
string strcn = ConfigurationManager.ConnectionStrings["WebOffice"].ConnectionString;
cn = new SqlConnection(strcn);
cn.Open();
string sql;
if (!String.IsNullOrEmpty(id))
{
sql = "update WebDoc Set DocContent=@DocContent where DocID=@ID";
cmd = new SqlCommand(sql, cn);
cmd.Parameters.Add("@ID",SqlDbType.Int).Value =id;
cmd.Parameters.Add("@DocContent", SqlDbType.Binary).Value = photoArray;
cmd.ExecuteNonQuery();
}
else
{
sql = "Insert into WebDoc(DocTitle,DocType,DocContent) values(@DocTitle,@DocType,@DocContent)";
cmd =new SqlCommand(sql,cn);
cmd.Parameters.Add("@DocTitle", SqlDbType.VarChar, 50).Value = docTitle;
cmd.Parameters.Add("@DocType", SqlDbType.VarChar, 10).Value = docType;
cmd.Parameters.Add("@DocContent", SqlDbType.Binary).Value = photoArray;
cmd.ExecuteNonQuery();
}
cn.Close();
Response.Write("succeed");
Response .End();
}
else
Response.Write("fail");
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询