jsp:
<form id="fileUploadForm" name="fileUploadForm" action="./wyqService.action" 
        enctype="multipart/form-data" method="post">
    <input type="file" name="file" id="file" size="40"/><br>
    <input type="submit" name="uploadButton" id="uploadButton" value="开始上传"/>
    <input type="button" name="cancelUploadButton" id="cancelUploadButton" value="取消上传"/><br>
</form>
action:
        BufferedOutputStream bos = null;
        BufferedInputStream bis = null;
        try {
            // 上传在临时目录的临时文件
            FileInputStream fis = new FileInputStream(file);
            bis = new BufferedInputStream(fis);
            // 指定的文件存放地点
            FileOutputStream fos = new FileOutputStream(new File(dir,
                    getFileFileName()));
            bos = new BufferedOutputStream(fos);
            // 转移文件
            byte[] buf = new byte[4096];
            int len = -1;
            while ((len = bis.read(buf)) != -1) {
                bos.write(buf, 0, len);
            }
            if (bis != null) {
                bis.close();
            }
            if (bos != null) {
                bos.close();
            }
            uploadary.add(getFileFileName() + "上传成功!");
        } catch (Exception e) {
            e.printStackTrace();
            uploadary.add(getFileFileName() + "上传失败!");
            if (bis != null) {
                try {
                    bis.close();
                } catch (IOException e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                }
            }
            if (bos != null) {
                try {
                    bos.close();
                } catch (IOException e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                }
            }