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();
    }
    )

  • 相关阅读:
    单点登陆的javascript类原创
    goole图标
    字符串string的相关应用
    今天心情好,发首我喜欢的歌天黑黑
    爱情幸福!
    linux虚拟实现
    页面显示的问题
    由我们MIS的老师,所引发的一点感想.
    有关PERL5和正则表达式
    本来没有什么好说的!
  • 原文地址:https://www.cnblogs.com/lingding/p/11151755.html
Copyright © 2011-2022 走看看