我们上传文件时需要修改PO发票生成器上的文件名

时间:2017-07-05 08:44:33

标签: coldfusion

        

    <cfif NOT DirectoryExists(ExpandPath(lv_upload_path))>
        <cfdirectory action="create"  directory="#ExpandPath(lv_upload_path)#">
    </cfif>

    <cfset lv_file_ext = listLast(FORM.filename_inv, ".") />

    <!--- replace special chars in comapny name except space, then replace space with underscore --->
    <cfset company_name = replaceSpecialChars(
        textString=FORM.company_name, 
        replaceTheseChars="33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,58,59,60,61,62,63,64,91,92,93,94,95,96,123,124,125,126"
    )>
    <cfset company_name = Replace( company_name, "#Chr(32)#", "_", "All" )>

    <cfset lv_file_name = company_name & "_Factura_" & replaceSpecialChars(FORM.in_supplier_inv) & "_" & DateFormat(FORM.in_when_inv, "dd.mm.yyyy") >
    <cfset lv_file_name_out = lv_file_name & "." & replaceSpecialChars(lv_file_ext)>

    <cffile action="upload" filefield="pickfiles_inv" destination="#ExpandPath(lv_upload_path & '/' & lv_file_name_out)#" nameconflict="MakeUnique">

    <cfset lv_document_name = CFFILE.serverfile />

    <cfset new_id = APPLICATION.po_management.f_savePOInvDocuments(
        p_po_inv_id=URL.id,
        p_supplier_number=FORM.in_supplier_inv,
        p_when_created=FORM.in_when_inv,
        p_amount=FORM.in_amount_inv,
        p_document_name=lv_document_name

我是新的,所以如果我提出不正确的问题,请帮助我们将来如何做得更好。

上传文件时返回错误

元素FILENAME_INV在FORM中未定义。

1 个答案:

答案 0 :(得分:0)

请改用以下行:

<cfset lv_file_ext = listLast(FORM.pickfiles_inv, ".") />