if ( uploadFile.PostedFile.FileName.Trim() != String.Empty )
{
//----------- update图片
Stream imagedatastream;
SqlConnection myConn=new SqlConnection(ConfigurationSettings.AppSettings["ConnStr"]);
imagedatastream = Request.Files["uploadFile"].InputStream ;
int imagedatalen = Request.Files["uploadFile"].ContentLength ;
string imagedatatype = Request.Files["uploadFile"].ContentType ; byte[] image = new byte[imagedatalen];
imagedatastream.Read(image,0,imagedatalen); String Psql="update Products set PPicture=@imgdata where PID=" + strPID; SqlCommand Pcommand=new SqlCommand(Psql,myConn); SqlParameter imgdata = new SqlParameter("@imgdata",SqlDbType.Image);
imgdata.Value=image;
Pcommand.Parameters.Add (imgdata); myConn.Open();
Pcommand.ExecuteReader();
myConn.Close();
//-----------
}
这是正确的二进制方式上传文件代码
但我现在不想用这方式了。想看到世界的名字和地址。该怎么改
不会不要回帖——————————

解决方案 »

  1.   

    就是入
    c://community.csdn.net/Expert/topic/5777/5777391.xml?
    而二进制传上去的是<Binary>
      

  2.   

    哪你再用1个nvarchar字段保存文件名就好了。你的数据库字段类型是Binary,显示的肯定是Binary的
      

  3.   

    数据库字段设置为mtext
    直接读取内容写入数据库
    http://dotnet.aspx.cc/article/78280914-a75c-40dc-9dac-322b3d81be35/read.aspx
      

  4.   

    imagedatatype 这里不是包含了文件的文件名和后缀点信息吗?
    从这里用Substring不就可以提取到实际的文件名吗?