zoukankan      html  css  js  c++  java
  • 文件上传后台

    public void addUpLoadFile(HTTPContext context) throws IOException {
            ServletFileUpload upload = new ServletFileUpload(new DiskFileItemFactory());
            upload.setHeaderEncoding("utf-8");
            List fileList = null;
            try {
                fileList = upload.parseRequest(context.request);
            } catch (FileUploadException ex) {
                ex.printStackTrace();
            }
            Iterator it = fileList.iterator();
            while (it.hasNext()) {
                FileItem item = (FileItem) it.next();
                if (!item.isFormField()) {
                    String name = item.getName();
                    if (item.getName() == null || item.getName().trim().equals("")) {
                        continue;
                    }
                    byte[] docBytes = IOUtils.toByteArray(item.getInputStream());
                    String fileType=item.getName().substring(item.getName().lastIndexOf(".")+1);
                    
                    byte[] pdfBytes = null;
                    SEntity sEntity = new SEntity("SYS_UPLOAD_FILE");
                    sEntity.setValue("CONTENT", docBytes);
                    sEntity.setValue("FILENAME", name);
                    sEntity.setValue("FILETYPE",fileType);
                    baseDao.save(sEntity);
                                
                    context.reply("上传成功!", 200);
                }
            }
  • 相关阅读:
    sort排序
    js数组
    json数据格式 与 for in
    js 定时器
    鼠标滚轮事件
    cookie
    POJ 2387 Til the Cows Come Home
    POJ 1459 Power Network
    HDU 5389 Zero Escape
    HDU 5387 Clock
  • 原文地址:https://www.cnblogs.com/clovem/p/6699715.html
Copyright © 2011-2022 走看看