用FileStream上传图片转换成二进制,在本地用行,传到服务器上去出现如下错误

http://topic.csdn.net/u/20090407/16/60225645-c334-4e0f-818c-cfd6565d716f.html

未能找到路径“C:/Documents and Settings/92724.jpg”的一部分。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。

异常详细信息: System.IO.DirectoryNotFoundException: 未能找到路径“C:/Documents and Settings/92724.jpg”的一部分。

 

怎么调..本地权限应该没问题,因为我在本地测没问题,而服务器权限应该还没到那个方面,因为它提示找不到本地路径...

所以我觉得是路径的问题,但是我不知道怎么改.代码如下..

 

C# code
  
  
string photoName1 = fileUp.PostedFile.FileName; // �获取初始文件名 FileStream fs = new FileStream(photoName1, FileMode.Open, FileAccess.Read, FileShare.Read); BinaryReader br = new BinaryReader(fs); byte [] photo = br.ReadBytes(( int )fs.Length); br.Close(); fs.Close(); OleDbCommand cmd = new OleDbCommand( " update people set photo=@photo,[update]=' " + this .time1.Text + " ',realname=' " + this .name1.Text + " ',title=' " + this .title1.Text + " ',intro=' " + this .con1.Text + " ',article=' " + this .come1.Text + " ' where id= " + Request[ " id " ], mycon_A); cmd.Parameters.Add( " @photo " , OleDbType.Binary, photo.Length).Value = photo; // 把图片的二进制加到DB中 cmd.ExecuteNonQuery();
你程序是运行在服务器的,你的文件是选择在客户端的,当然报图片不存在。。 

Stream fs = fileUp.PostedFil.InputStream;

BinaryReader br = new BinaryReader(fs);
byte[] photo = br.ReadBytes((int)fs.Length);
br.Close();
fs.Close();

OleDbCommand cmd = new OleDbCommand("update people set photo=@photo,[update]='" + this.time1.Text + "',realname='" + this.name1.Text + "',title='" + this.title1.Text + "',intro='" + this.con1.Text + "',article='" + this.come1.Text + "' where id=" + Request["id"], mycon_A);
                             
cmd.Parameters.Add("@photo", OleDbType.Binary, photo.Length).Value = photo;//把图片的二进制加到DB中
cmd.ExecuteNonQuery();
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值