文章教程

JavaServlet的文件上传和下载实现方法

5/9/2018 9:58:32 PM 人评论 次浏览

先分析一下上传文件的流程

1-先通过前段页面中的选择文件选择要上传的图片

index.jsp

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"
 contentType="text/html; charset=UTF-8"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
 <head>
  <title>My JSP 'index.jsp' starting page</title>
  <meta http-equiv="content-type" content="text/html;charset=utf-8">
  <meta http-equiv="pragma" content="no-cache">
  <meta http-equiv="cache-control" content="no-cache">
  <meta http-equiv="expires" content="0">
  <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
  <meta http-equiv="description" content="This is my page">
  
  <script type="text/javascript" src="js/jquery.min.js"></script>
  <script type="text/javascript" src="js/common.js"></script>
  <script type="text/javascript" src="js/ajaxfileupload.js"></script>
 </head>
 <body>
  <input type="file" value="上传" name="inputImage" id="inputImage">
  <input type="button" value="上传" id="upload">
  
  <a id="downLoad">下载</a>
 </body>
</html>