int len = request.getContentLength();
byte buffer[] = new byte[len];
解决方案 »
- Spring <aop:config>疑问
- 严重: Exception sending context initialized event to listener instance of class or
- 请教spring高手关于spring引用引介的问题
- JMX监控weblogic问题
- 同一段连数据库代码在普通类里可以用,但在servlet里却说找不到OracleDriver
- hibernate中不是主键但是要自动增长如何设置配置文件
- 关于《Spring2.0中文参考手册(中文版)》的问题
- 帮帮忙????struts问题!
- ◆◇怎么写一个程序,让它不停地扫描数据库,挑选状态为1的数据并放到recordset中◇◆
- 跳转问题i
- 请教分页问题(关于分页表数据实时变化)
- strtus2见鬼的问题
// int len = 0;
// byte[] bytes = new byte[1024];
// while((len = in.read(bytes))!=-1){
// fos.write(bytes, 0, len);
// fos.flush();
// }
// fos.close();确实是把文件写下来了,但因为需求需要写到一个字节数组中,现在写不进去
// int len = 0;
// byte[] bytes = new byte[1024];
// while((len = in.read(bytes))!=-1){
// fos.write(bytes, 0, len);
// fos.flush();
// }
// fos.close();确实是把文件写下来了,但因为需求需要写到一个字节数组中,现在写不进去你不是上传吗?
表单的enctype="multipart/form-data" 是否设置了?
是post请求吧?
如果是get请求length是-1
// int len = 0;
// byte[] bytes = new byte[1024];
// while((len = in.read(bytes))!=-1){
// fos.write(bytes, 0, len);
// fos.flush();
// }
// fos.close();确实是把文件写下来了,但因为需求需要写到一个字节数组中,现在写不进去你不是上传吗?
表单的enctype="multipart/form-data" 是否设置了?
是post请求吧?
如果是get请求length是-1
android客户端传上来的,等下跟他们确认下,刚用了个笨方法File file = new File("F:\\abc.jpg");
FileOutputStream fos = new FileOutputStream(file);
int len = 0;
byte[] bytes = new byte[1024];
while((len = in.read(bytes))!=-1){
fos.write(bytes, 0, len);
fos.flush();
}
fos.close();
System.out.println(file.length());
in = new FileInputStream(file);
byte[] temp = new byte[(int) file.length()];
in.read(temp);先写入一个临时文件,在获取文件的大小,然后就成功了。
// int len = 0;
// byte[] bytes = new byte[1024];
// while((len = in.read(bytes))!=-1){
// fos.write(bytes, 0, len);
// fos.flush();
// }
// fos.close();确实是把文件写下来了,但因为需求需要写到一个字节数组中,现在写不进去你不是上传吗?
表单的enctype="multipart/form-data" 是否设置了?
是post请求吧?
如果是get请求length是-1
请问下如果是get方式提交的话,有没有其他办法获取到上传上来的文件的大小的