8 个解决方案
#1
用上传下载的组件,比如smartupload
#2
帮顶,有没有纯用代码实现的方法?
#3
http://www.google.cn/search?hl=zh-CN&newwindow=1&q=jsp%E4%B8%8A%E4%BC%A0%E4%B8%8B%E8%BD%BD&aq=0g&oq=JSP+%E4%B8%8A%E4%BC%A0xia
网上很多,看看就明白,也不是什么深奥的东西
网上很多,看看就明白,也不是什么深奥的东西
#4
smartupload已经是纯代码了。。。。
#5
选择上传图片:<input type="file" name="file" class="btnload">
上传操作
<%
SmartUpload mySmartUpload =new SmartUpload();
String ext="";
//初始化
mySmartUpload.initialize(pageContext);
try {
//只允许上载此类文件
mySmartUpload.setAllowedFilesList("jpg,gif");
//上载文件
mySmartUpload.upload();
} catch (Exception e){
}
try{
com.jspsmart.upload.File myFile = mySmartUpload.getFiles().getFile(0);
ext = myFile.getFileExt(); //取得后缀名
String myFileName = myFile.getFileName(); //取得上载的文件的文件名
myFileName = myFileName.substring(0,myFileName.length() - ext.length() - 1);
String saveurl = "";
saveurl = "pic/" + oid + "." + ext;
myFile.saveAs(saveurl);
}catch (Exception e){
out.println(e.toString());
}
%>
上传操作
<%
SmartUpload mySmartUpload =new SmartUpload();
String ext="";
//初始化
mySmartUpload.initialize(pageContext);
try {
//只允许上载此类文件
mySmartUpload.setAllowedFilesList("jpg,gif");
//上载文件
mySmartUpload.upload();
} catch (Exception e){
}
try{
com.jspsmart.upload.File myFile = mySmartUpload.getFiles().getFile(0);
ext = myFile.getFileExt(); //取得后缀名
String myFileName = myFile.getFileName(); //取得上载的文件的文件名
myFileName = myFileName.substring(0,myFileName.length() - ext.length() - 1);
String saveurl = "";
saveurl = "pic/" + oid + "." + ext;
myFile.saveAs(saveurl);
}catch (Exception e){
out.println(e.toString());
}
%>
#6
guan zhu
#7
有没用IO写的?不用组件
#8
sturts上传就可传图片。
#1
用上传下载的组件,比如smartupload
#2
帮顶,有没有纯用代码实现的方法?
#3
http://www.google.cn/search?hl=zh-CN&newwindow=1&q=jsp%E4%B8%8A%E4%BC%A0%E4%B8%8B%E8%BD%BD&aq=0g&oq=JSP+%E4%B8%8A%E4%BC%A0xia
网上很多,看看就明白,也不是什么深奥的东西
网上很多,看看就明白,也不是什么深奥的东西
#4
smartupload已经是纯代码了。。。。
#5
选择上传图片:<input type="file" name="file" class="btnload">
上传操作
<%
SmartUpload mySmartUpload =new SmartUpload();
String ext="";
//初始化
mySmartUpload.initialize(pageContext);
try {
//只允许上载此类文件
mySmartUpload.setAllowedFilesList("jpg,gif");
//上载文件
mySmartUpload.upload();
} catch (Exception e){
}
try{
com.jspsmart.upload.File myFile = mySmartUpload.getFiles().getFile(0);
ext = myFile.getFileExt(); //取得后缀名
String myFileName = myFile.getFileName(); //取得上载的文件的文件名
myFileName = myFileName.substring(0,myFileName.length() - ext.length() - 1);
String saveurl = "";
saveurl = "pic/" + oid + "." + ext;
myFile.saveAs(saveurl);
}catch (Exception e){
out.println(e.toString());
}
%>
上传操作
<%
SmartUpload mySmartUpload =new SmartUpload();
String ext="";
//初始化
mySmartUpload.initialize(pageContext);
try {
//只允许上载此类文件
mySmartUpload.setAllowedFilesList("jpg,gif");
//上载文件
mySmartUpload.upload();
} catch (Exception e){
}
try{
com.jspsmart.upload.File myFile = mySmartUpload.getFiles().getFile(0);
ext = myFile.getFileExt(); //取得后缀名
String myFileName = myFile.getFileName(); //取得上载的文件的文件名
myFileName = myFileName.substring(0,myFileName.length() - ext.length() - 1);
String saveurl = "";
saveurl = "pic/" + oid + "." + ext;
myFile.saveAs(saveurl);
}catch (Exception e){
out.println(e.toString());
}
%>
#6
guan zhu
#7
有没用IO写的?不用组件
#8
sturts上传就可传图片。