Storing file name when uploading using Coldfusion

前端 未结 3 1758
遇见更好的自我
遇见更好的自我 2021-01-20 21:13

I am trying to store the filename of the selected file to be uploaded into a hidden input field on the form. my form looks like this

3条回答
  •  无人共我
    2021-01-20 21:30

    You can find the file name before saving.

    Railo:

    GetPageContext().formScope().getUploadResource("myFormField").getName()
    

    Adobe:

    function getClientFileName(fieldName) {
    var tmpPartsArray = Form.getPartsArray();
    var clientFileName = "";
    
    if (IsDefined("tmpPartsArray")) {
        for (local.tmpPart in tmpPartsArray) {
            if (local.tmpPart.isFile() AND local.tmpPart.getName() EQ arguments.fieldName) {
                return local.tmpPart.getFileName();
                }
            }
        }
    
    return "";
    }
    

    Source: http://www.stillnetstudios.com/get-filename-before-calling-cffile/

提交回复
热议问题