求一个jsp实现上传功能,不使用任何组件

最近公司需要这么一个功能,但是原来使用的commons-fileupload-1.2.jar包在客户现场可能是因为网络问题,上传多个文件的时候经常出错,希望找一个纯jsp实现的方式~

传个URI上去吧,然后再后台去读取相关的流,这样做就很纯了

你去看下URI的那个类吧,绝对路径你可以根据IP去拼的啊

直接使用字节流就可以了
oldfile要上传的文件
newPathFile上传后文件存放的路径
public static int copyFile(File oldfile, String newPathFile) {
int bytesum = 0;
int byteread = 0;
if (oldfile.exists()) { // 有文件
InputStream inStream = new FileInputStream(oldfile.getPath()); // 读入原文件
FileOutputStream fs = new FileOutputStream(newPathFile);
byte[] buffer = new byte[1444];
while ((byteread = inStream.read(buffer)) != -1) {
bytesum += byteread; // 字节数 文件大小
// System.out.println(bytesum);
fs.write(buffer, 0, byteread);
}
fs.close();
inStream.close();
return 1;
}