问题代码如下:
private static ImageStruct InitImageWidthAndHeight(HttpPostedFile postFile)
{
int byteLenght = postFile.ContentLength;
Byte[] TempBytes = new byte[byteLenght]; postFile.InputStream.Read(TempBytes, 0, byteLenght); MemoryStream stream = new MemoryStream(TempBytes);
****Image img = Image.FromStream(stream);*****
ImageStruct imgStruct;
imgStruct.Height = img.Height;
imgStruct.Width = img.Width;
-----------------------
return imgStruct;
}
循环调用此方法,以实现上传多个图片,但只能上传一张,第二张时就会出错!****处报错"参数无效"
找半天后发现TempBytes数组是空的,里面元素值全为0,在---------处加代码:
"postFile.InputStream.Flush();postFile.InputStream.Close();"
后报错"内存不足",请高手不吝赐教!
private static ImageStruct InitImageWidthAndHeight(HttpPostedFile postFile)
{
int byteLenght = postFile.ContentLength;
Byte[] TempBytes = new byte[byteLenght]; postFile.InputStream.Read(TempBytes, 0, byteLenght); MemoryStream stream = new MemoryStream(TempBytes);
****Image img = Image.FromStream(stream);*****
ImageStruct imgStruct;
imgStruct.Height = img.Height;
imgStruct.Width = img.Width;
-----------------------
return imgStruct;
}
循环调用此方法,以实现上传多个图片,但只能上传一张,第二张时就会出错!****处报错"参数无效"
找半天后发现TempBytes数组是空的,里面元素值全为0,在---------处加代码:
"postFile.InputStream.Flush();postFile.InputStream.Close();"
后报错"内存不足",请高手不吝赐教!
解决方案 »
- gridview绑定SqlDataReader之后,如何指定某列可编辑?
- .NET如何记录文件路径呢?
- JS提示,主機喇叭響。
- 都说asp.net的机制是编译可我怎么觉得他即是编译又是解释呢????就好比叫一个副经理为经理一样,微软老是拔高自己????
- FCKeditor 上传文件的出错请高手进来帮我看看
- 请教:winNT能配置asp.net的服务器开发环境吗?如何配置?
- 一个新手的问题,水晶报表用向导新建的报表,数据源采用ASP.NET的DataSet,无法使用Toolbar上的按钮。
- 用中文做虚拟目录时,无法显示,,URL中中文变成乱码,,怎么办!!
- 中文版转英文版!!!
- 找两本书:《asp.net高级控件编程》、Developing Microsoft ASP.NET Server Controls and Components。有谁有下载地址吗?万分感谢!
- 怎样在程序里判断sqlDatasource没有返回数据,或者说返回的数据为空?
- Datagrid 绑顶 ArrayList 出错
{
}必须把 stream 关掉!