Feature in evalFile() corrected

View: New views
1 Messages — Rating Filter:   Alert me  

Feature in evalFile() corrected

by Franz Philipp Moser :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi List,

don't know if anybody interested, but I found some strange behavior when
uploading files with more than one dot in the filename, like
filename.tar.gz or filename.user.js. The last extention got truncated
because in FileMgr/objectFunctions()@line 36 you do the following:

newFile.name = newFile.alias;

this is ok if the user specifies an alias but not if the alias is build
from filename. I think that param.rawfile.writeToFile does not append
the file extention correct because there is already a dot in the filename.

I have rewritten the evalFile Function to the following (near line 25):

<codesnippet>
    // if no alias given try to determine it
    var fileExt = "";
    if (!param.alias) {
       newFile.alias = buildAliasFromFile(param.rawfile, this);
       var fileName = param.rawfile.getName().split("/").pop();
       if (fileName.split(".").length > 1) {
          fileExt = fileName.substring(fileName.lastIndexOf("."),
fileName.length)
       }
    } else {
       if (!param.alias.isFileName())
          throw new Exception("noSpecialChars");
       newFile.alias = buildAlias(param.alias, this);
    }
    // store properties necessary for file-creation
    newFile.alttext = param.alttext;
    // correct File Extentions
    newFile.name = newFile.alias + fileExt;
</codesnippet>

cu Philipp
--
XML is the ASCII for the new millenium
(Cocoon Documentation)
_______________________________________________
Antville-dev mailing list
Antville-dev@...
http://helma.org/mailman/listinfo/antville-dev
LightInTheBox - Buy quality products at wholesale price!