文件上傳功能是最基本的
Java代碼
=========文件上傳功能================
@Property
private UploadedFile file;
@Inject
private ApplicationGlobals globals;
//獲得絕對路徑
String path = globals
File copied = new File(path +
file
function fileBtn(){
var file=document
//var houzui=kzName(file);
//獲取文件後綴名並轉成小寫
var ext=file
if( file
alert(
return false;
}else{
if(ext!=
alert(
return false;
}
}
return true;
}
//獲取後綴名
function kzName(u)
{
var s = /
return (s!=null)?s[
}
=============file
<div id=
<t:form>
圖片上傳
<input t:type=
<input type=
</t:form>
<!
<div><span id=
</div>
===============file
@Property
private UploadedFile file;
@Persist(PersistenceConstants
@Property
private String message;
@Inject
private Messages messages;
@Property
@Persist(value=
private int errorCode;
Object onUploadException(FileUploadException ex)
{
message =
return this;
}
//用來在頁面做提示信息
public String getErrorMsg(){
switch (errorCode) {
case
return messages
case
return messages
default:
break;
}
return
}
From:http://tw.wingwit.com/Article/program/Java/hx/201311/25990.html