void write(Java
A convenience method to write an uploaded item to disk
而這裡的是String!!!
Constructor Summary
File(File parent
Creates a new File instance from a parent abstract pathname and a child pathname string
File(String pathname)
Creates a new File instance by converting the given pathname string into an abstract pathname
File(String parent
Creates a new File instance from a parent pathname string and a child pathname string
File(URI uri)
Creates a new File instance by converting the given file: URI into an abstract pathname
我修改了這句為兩句:
File writeFile=new File(
fi
這樣這個上傳程序終於可以工作了!(一會有源代碼
還有這裡的
其它過程:
B 端的上傳
upload目錄:
<form action=
這裡oc
請輸入要上傳的文件:<input type=
S端讀取:
public ServletInputStream getInputStream() throws java
temp sql:
create table upload(
name varchar
content clob );
commit;
server 端接受文件上傳
說明:
Commons是 Apache開放源代碼組織中的一個Java子項目
PS:一般下載的*
另外
Reference:
我寫的參考源代碼:
//inputupload
<%@ page contentType=
<html>
<head>
<meta http
<title>inputUpload</title>
</head>
<body>
<%
request
%>
<form action=
請輸入要上傳的文件:<input type=
<input type=
</form>
</body>
</html>
//getUpload
<%@ page contentType=
<%@ page import=
<%@ page import=
<%@ page import=
<%@ page import=
getUpload
<%
DiskFileUpload dfu = new DiskFileUpload();
// 設置允許用戶上傳文件大小
dfu
// maximum size that will be stored in memory?
// 設置最多只允許在內存中存儲的數據
dfu
// 設置一旦文件大小超過getSizeThreshold()的值時數據存放在硬盤的目錄
dfu
//開始讀取上傳信息
try{
List fileItems = dfu
%>
<%
// 依次處理每個上傳的文件
Iterator i = erator();
String name =null;
long size=
while (i
{
FileItem fi = (FileItem) i
//忽略其他不是文件域的所有表單信息
if (!fi
name = fi
size = fi
if((name==null||name
continue; }
name=fi
size=fi
name = name
name = name
File writeFile=new File(
fi
}
}catch(FileUploadException fue)
{ fue
%>
From:http://tw.wingwit.com/Article/program/Java/hx/201311/26969.html