📄 forumfileupload.java
字号:
package com.redmoon.forum.util;import java.io.*;import java.util.*;import cn.js.fan.util.*;import com.cloudwebsoft.framework.util.*;import com.redmoon.forum.*;import com.redmoon.kit.util.*;public class ForumFileUpload extends FileUpload { String remoteBasePath; public void setRemoteBasePath(String remoteBasePath) { this.remoteBasePath = remoteBasePath; } public ForumFileUpload() { } public void writeFile(boolean isRandName) { Vector files = getFiles(); int size = files.size(); if (size == 0) return; Config cfg = Config.getInstance(); boolean isFtpUsed = cfg.getBooleanProperty("forum.ftpUsed"); FTPUtil ftp = new FTPUtil(); if (isFtpUsed) { try { boolean retFtp = ftp.connect(cfg.getProperty( "forum.ftpServer"), cfg.getIntProperty("forum.ftpPort"), cfg.getProperty("forum.ftpUser"), cfg.getProperty("forum.ftpPwd"), true); if (!retFtp) { LogUtil.getLog(getClass()).error("writeFile:" + ftp.getReplyMessage()); } else { if (remoteBasePath.lastIndexOf("/") != remoteBasePath.length() - 1) remoteBasePath += "/"; java.util.Iterator ir = files.iterator(); while (ir.hasNext()) { FileInfo fi = (FileInfo) ir.next(); try { String fname = ""; if (!isRandName) fname = fi.getName(); else { fname = FileUpload.getRandName() + "." + fi.getExt(); } fi.diskName = fname; ftp.storeFile(remoteBasePath + fname, fi.getTmpFilePath()); } catch (IOException e1) { LogUtil.getLog(getClass()).error( "AddNewWE: storeFile - " + e1.getMessage()); } } } } finally { ftp.close(); } } else { java.util.Iterator ir = files.iterator(); while (ir.hasNext()) { FileInfo fi = (FileInfo) ir.next(); if (!isRandName) fi.write(savePath, ""); else fi.write(savePath, getRandName() + "." + fi.getExt()); } } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -