最近用java实现FTP文件夹上传时,只能传tomcat服务器上的文件夹,而不能传web客户端的文件夹,请问是什么原因,如何修改?先谢谢了。
    上传文件夹的核心代码如下:
/**
 * 上传文件或文件夹
 */
public void upload(File file, ProgressListener listener) throws Exception
{
ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE);
ftpClient.enterLocalPassiveMode();
ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE);

/**
 * File.isDirectory():
 *   Tests whether the file denoted by this abstract pathname is a directory
 *   测试当前file对象表示的文件是否是一个路径
 */ if(file.isDirectory())
{
/**
 * File.getName()
 *   Returns the name of the file or directory denoted by this abstract pathname
 *   返回表示当前对象的文件名
 */
ftpClient.makeDirectory(file.getName());

ftpClient.changeWorkingDirectory(file.getName());

/**
 * File.list() 
 *   Returns an array of strings naming the files and directories in the directory denoted by this abstract pathname
 *   返回当前File对象指定的路径文件列表
 */
String[] files = file.list();

for(int i=0; i<files.length; i++)
{
/**
 * File.getPath()
 *   Converts this abstract pathname into a pathname string.
 *   输出:D:\a\x.flv
 */
File file1 = new File(file.getPath()+"\\"+files[i]);

if(file1.isDirectory())
{
upload(file1, listener);
ftpClient.changeToParentDirectory();
}
else
{ File file2 = new File(file.getPath()+"\\"+files[i]);
System.out.println("else分支中  " + file.getPath()+"\\"+files[i]);
System.out.println("else分支中 file2.getName() = " + file2.getName());

InputStream input = new FileInputStream(file2);

int n = -1;
/**
 * InputStream.available()
 *   Returns an estimate of the number of bytes that can be read(or slipped over) from this input stream
 *   without blocking by the next invocation of a method for this input stream
 */
long pContentLength = input.available();
System.out.println("else分支中 pContentLength= " + pContentLength);
System.out.println("--------------------------------------------");

long trans = 0;

/**
 * bufferSize = 1024
 */
int bufferSize = ftpClient.getBufferSize();

byte[] buffer = new byte[bufferSize];

OutputStream os = ftpClient.storeFileStream(file2.getName());

/**
 * FileInputStream.read(byte[] b)
 *   Reads up to b.length bytes of data from this input stream into an array of bytes
 */
while((n = input.read(buffer)) != -1)
{
/**
 * OutputStream.write(byte[] b, int off, int len)
 *   Writes len bytes from the specified byte array starting at offset off to this output stream
 */
os.write(buffer, 0, n);
trans += n;
listener.update(trans, pContentLength, i+1);
}

input.close();
os.flush();
os.close();

ftpClient.completePendingCommand();
}
}
}
else
{
File file3 = new File(file.getPath());

InputStream input = new FileInputStream(file3);

int n = -1;
/**
 * InputStream.available()
 *   Returns an estimate of the number of bytes that can be read(or slipped over) from this input stream
 *   without blocking by the next invocation of a method for this input stream
 */
long pContentLength = input.available(); long trans = 0;

/**
 * bufferSize = 1024
 */
int bufferSize = ftpClient.getBufferSize();

byte[] buffer = new byte[bufferSize];

OutputStream os = ftpClient.storeFileStream(file3.getName());

/**
 * FileInputStream.read(byte[] b)
 *   Reads up to b.length bytes of data from this input stream into an array of bytes
 */
while((n = input.read(buffer)) != -1)
{
/**
 * OutputStream.write(byte[] b, int off, int len)
 *   Writes len bytes from the specified byte array starting at offset off to this output stream
 */
os.write(buffer, 0, n);
trans += n;
listener.update(trans, pContentLength, 1);
}

input.close();
os.flush();
os.close();

ftpClient.completePendingCommand();
}
}FTP上传FTPClient