站内搜索: 请输入搜索关键词

当前页面: 开发资料首页JSP 专题如何往 http://192.168.0.1/test 这个文件夹里传文件

如何往 http://192.168.0.1/test 这个文件夹里传文件

摘要: 如何往 http://192.168.0.1/test 这个文件夹里传文件


ftp我用过了可以的
有没有在服务器端不开服务就可以传文件的
对方的用户密码都可以知道的
用java写


http??
you can use HTTP put, but you need a form on the page.



ding


能提供一下代码吗,我这完全没有头绪


搜索 smartupload 再看看例子就会明白地~~~


FileOperateForm fileform=(FileOperateForm)form;
FormFile file=fileform.getTheFile();//取得上传的文件

int sign=0;
try {
InputStream stream = file.getInputStream();//把文件读入
String filePath = "C://file";//取当前系统路径
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream bos = new FileOutputStream(filePath + "/" +file.getFileName());//建立一个上传文件的输出流
int size=file.getFileSize();
int bytesRead = 0;
byte[] buffer = new byte[size];
while ( (bytesRead = stream.read(buffer, 0, size)) != -1) {
bos.write(buffer, 0, bytesRead);//将文件写入服务器
}
bos.close();
stream.close();
sign=1;
}catch(Exception e){
e.printStackTrace();
sign=0;
}



能把文件写到http://192.168.0.1/test 这个文件夹下吗?



Hacking ?


↑返回目录
前一篇: 网站架构问题
后一篇: 请教图片转换的例子,高分求助(100)