一个简单的asp.net问题 - .NET技术 / ASP.NET
protected void Button2_Click(object sender, EventArgs e)
{
Stream imaDataStream = FileUpload1.PostedFile.InputStream;
int imgDataLen = FileUpload1.PostedFile.ContentLength;
byte[]bytesoriginal=new byte[imgDataLen];
int n = imaDataStream.Read(bytesoriginal,0,imgDataLen);
Addphoto(1,Caption,bytesoriginal);
Label5.Text = "相片上传成功!";
}
}
byte[]bytesoriginal=new byte[imgDataLen];
int n = imaDataStream.Read(bytesoriginal,0,imgDataLen);这两句的运行机制是怎么样的呢?read()里面的三个参数是怎么联系的呢?把第二和第三个参数放进bytesoriginal里吗?
(3) Addphoto(1,Caption,bytesoriginal);里面那个1是做什么的;
谢谢
看msdn帮助文档吧,你就知道Read方法里三个参数的含义了。
另外你这个Addphoto明显是一个自定的方法,这个是你下载的吧,那个参数估计就是添加一张照片的意思吧。
msdn非常详细
http://msdn.microsoft.com/zh-cn/library/system.io.stream.read%28VS.80%29.aspx
参数
buffer
字节数组。此方法返回时,该缓冲区包含指定的字符数组,该数组的 offset 和 (offset + count -1) 之间的值由从当前源中读取的字节替换。
offset
buffer 中的从零开始的字节偏移量,从此处开始存储从当前流中读取的数据。
count
要从当前流中最多读取的字节数。
相关问答:
function CheckOpwd(){//验证用户名
var pwd=document.all.txtOpwd;
var div1=document.getElementById("divPwd");
if (pwd.value=="")
{
......
在asp里怎么调用java写的webservice方法,有很多方法
- <message name="RtPnrIn">
<part name="bstrPnrNO" type="s:string" />
<part name ......
C# code:
SqlConnection conn = CsDB.sqlcon();
SqlDataAdapter da = new SqlDataAdapter("select fwCoding from bjmuma_fwCoding where OrderNumber='" + Order + & ......
就是一个按钮,点击之后打开对话框,然后选取图片。就这样上传。。
怎么实现。在网上搜到那么多的代码,全是很多的那种,不知道,看不下去。
所以在这里想请大哥大姐帮帮忙。
使用自带的fileupload控件可以实现 ......