zoukankan      html  css  js  c++  java
  • 上传图片

    本地上传 照片 到 服务器 总结 :
    第一步 :页面 (<td><input id="imageFile" name="file" type="file"/>)
    这里的 类型 为 type name 为 file
    第二步后台action:(定义私有变量
    private File file; 加上get he set 方法
    feeService.saveAccountData(paraMaps ,file);
    第三步:
    // 上传文件保存 // 文件名称
    if (file!=null && StringUtils.isNotEmpty(fiName)) {
    File dirFile = new File("/home/mis/transAccount");
    if (dirFile.exists() == false) {
    dirFile.mkdirs();
    }//不存在这个 路径 就创建
    File newFile = new File("/home/mis/transAccount" + "/" + fiName);
    copy(file, newFile);//写入 输入输出流
    cfa.setFileName(fiName);
    cfa.setFilePath(FileParamter.tranAccountPath);
    }
    第四步:
    InputStream in = null;
    OutputStream out = null;
    try {
    in = new BufferedInputStream(new FileInputStream(src), FileParamter.BUFFER_SIZE);
    out = new BufferedOutputStream(new FileOutputStream(dst), FileParamter.BUFFER_SIZE);
    byte[] buffer = new byte[FileParamter.BUFFER_SIZE];
    while (in.read(buffer) > 0) {
    out.write(buffer);
    }
    } finally {
    if (null != in) {
    in.close();
    }
    if (null != out) {
    out.close();
    }
    )

  • 相关阅读:
    centos 7 安装ntp服务器
    centos 7编译安装nodejs 6.1
    修改IKAnalyzer配置
    Elasticsearch5.5.0安装head插件
    搭建ELASTICSEARCH实现中文分词搜索功能
    0426HTML基础:标签
    事件事件流
    纯css设置各行变色
    dom操作之元素的增删复制
    dom操作
  • 原文地址:https://www.cnblogs.com/lingding/p/11151755.html
Copyright © 2011-2022 走看看