需匯入套件

目前沒時間解釋。

使用smartupload 需在WEB-INF匯入 classes等檔案。

https://drive.google.com/file/d/0By957BUEpZD4bURGeTcxcWxnYVE/view

若連結還沒死 可以下載看看(若怕毒就不要下載,我是作筆記,給需要幫助的人)

解壓縮後全部丟到WEB-INF\ 底下就可以了

 

uploadForm.html
<html>
<head>
<title></title>
</head>
<body>
<form action="usingsmartupload.jsp" enctype="multipart/form-data" name=theFile method="post" >
<input type=file name=File1 size=50 /> <br>
<input type=submit name=submitButton value="上傳" />
</form>
</body>
</html>

 

usingsmartupload.jsp
<%@page contentType="text/html"%>
<%@page pageEncoding="Big5"%>
<%@page import="com.jspsmart.upload.*" %>
<jsp:useBean id="theSmartUpload" scope="page" class="com.jspsmart.upload.SmartUpload" />
<html>
<head><title>上傳檔案作業</title></head>
<body>
<%
theSmartUpload.initialize(pageContext) ;
theSmartUpload.setTotalMaxFileSize(5*1024*1024) ;
theSmartUpload.setAllowedFilesList("txt,pdf") ;
theSmartUpload.upload() ;

//int fileCount=theSmartUpload.save("D:\\") ;
Files theFiles = theSmartUpload.getFiles() ;
File theFile =theFiles.getFile(0) ;
theFile.saveAs("D:\\copy_."+theFile.getFileExt(),theSmartUpload.SAVE_AUTO) ;
out.println("成功上傳"+"D:\\copy_."+theFile.getFileExt()) ;
//修改路徑即可
%>
</body>
</html>

arrow
arrow
    文章標籤
    IO JSP smartupload
    全站熱搜

    penguin1989930 發表在 痞客邦 留言(0) 人氣()