When one submits file upload form from Windows to
Linux server, then HtmlFileUpload.setShortFileName()
return file with full path. This is because filename is
submited with backslash but on Linux Java uses slash
as File.separator. There is a patch which solved the
problem for me.
Tomas Polak
/**
* This method extracts the file name from a directory.
* @param sFileName String
*/
private String setShortFileName(String sFileName) {
if (sFileName == null) {
_shortFileName = null;
return _shortFileName;
}
int iIdx = sFileName.lastIndexOf(File.separator);
//PATCHED: TP
//added code
if (iIdx < 0) {
iIdx = sFileName.lastIndexOf("\\");
}
if( iIdx < 0) {
iIdx = sFileName.lastIndexOf("/");
}
//end of patch
if (iIdx < 0) {
_shortFileName = sFileName;
return _shortFileName;
}
_shortFileName = sFileName.substring(iIdx + 1,
sFileName.length());
return _shortFileName;
}
Logged In: YES
user_id=552328
Tomas tested the following code which works, the following
solution is a more platform independent solution.
/**
* This method extracts the file name from a directory.
* @param sFileName String
*/
private String setShortFileName(String sFileName) {
if (sFileName == null) {
_shortFileName = null;
return _shortFileName;
}
File f=new File(sFileName);
_shortFileName = f.getName();
return _shortFileName;
}
Thanks
Fred