template::util::file_transform (public)

 template::util::file_transform element_id

Defined in packages/acs-templating/tcl/file-procs.tcl

Helper proc, which gets AOLserver/NaviServer's variables from the query/form, and returns it as a 'file' datatype value.

Parameters:
element_id (required)
Returns:
the list { file_name temp_file_name content_mime_type }.

Partial Call Graph (max 5 caller/called nodes):
%3 test_fs_upload_a_notmpfile fs_upload_a_notmpfile (test file-storage) template::util::file_transform template::util::file_transform test_fs_upload_a_notmpfile->template::util::file_transform test_template_widget_file template_widget_file (test acs-templating) test_template_widget_file->template::util::file_transform _ _ (public) template::util::file_transform->_ packages/acs-subsite/www/user/portrait/upload.tcl packages/acs-subsite/ www/user/portrait/upload.tcl packages/acs-subsite/www/user/portrait/upload.tcl->template::util::file_transform template::data::transform::file template::data::transform::file (private) template::data::transform::file->template::util::file_transform template::data::transform::richtext_or_file template::data::transform::richtext_or_file (public) template::data::transform::richtext_or_file->template::util::file_transform

Testcases:
template_widget_file, fs_upload_a_notmpfile
Source code:
    #
    # Check if these have already been converted, then return them as they are.
    #
    # This may happen, for instance, during the 'preview' action of a form.
    #
    if { [ns_queryget $element_id.tmpfile] eq "" } {
        set files [ns_querygetall $element_id]
    } else {
        if {[ns_info name] eq "NaviServer"} {
            #
            # NaviServer
            #
            # Get the files information using 'ns_querygetall'
            #
            set filenames [ns_querygetall $element_id]
            set tmpfiles  [ns_querygetall $element_id.tmpfile]
            set types     [ns_querygetall $element_id.content-type]
        } else {
            #
            # AOLserver
            #
            # ns_querygetall behaves differently in AOLserver, using the ns_queryget
            # legacy version instead
            #
            set filenames [ns_queryget $element_id]
            set tmpfiles  [ns_queryget $element_id.tmpfile]
            set types     [ns_queryget $element_id.content-type]
        }
        #
        # No files, get out
        #
        if {$filenames eq ""} {
            return ""
        }
        #
        # Return the files info in a list per file
        #
        set files [list]
        for {set file 0} {$file < [llength $filenames]} {incr file} {
            set filename [lindex $filenames $file]
            set tmpfile  [lindex $tmpfiles $file]
            set type     [lindex $types $file]
            #
            # Cleanup filenames
            #
            regsub -all -- {\\+} $filename {/} filename
            regsub -all -- { +} $filename {_} filename
            set filename [lindex [split $filename "/"] end]
            #
            # Append to the list of lists
            #
            lappend files [list $filename $tmpfile $type]
        }
    }

    return $files
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: