Index: openacs-4/packages/xowiki/tcl/xowiki-www-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/xowiki-www-procs.tcl,v diff -u -r1.175 -r1.176 --- openacs-4/packages/xowiki/tcl/xowiki-www-procs.tcl 24 Sep 2008 09:57:13 -0000 1.175 +++ openacs-4/packages/xowiki/tcl/xowiki-www-procs.tcl 25 Sep 2008 13:38:43 -0000 1.176 @@ -731,11 +731,16 @@ } default { # user form content fields - set f [my lookup_form_field -name $att $form_fields] - set value [$f value [string trim [::xo::cc form_parameter $att]]] - #my msg "value of $att ($f) = '$value'" - if {![string match *.* $att]} {set __ia($att) $value} - if {[$f exists is_category_field]} {foreach v $value {lappend category_ids $v}} + if {[regexp {^(.+)[.](tmpfile|content-type)} $att _ file field]} { + set f [my lookup_form_field -name $file $form_fields] + $f $field [string trim [::xo::cc form_parameter $att]] + } else { + set f [my lookup_form_field -name $att $form_fields] + set value [$f value [string trim [::xo::cc form_parameter $att]]] + #my msg "value of $att ($f) = '$value'" + if {![string match *.* $att]} {set __ia($att) $value} + if {[$f exists is_category_field]} {foreach v $value {lappend category_ids $v}} + } } } if {[string match *.* $att]} { @@ -1262,6 +1267,7 @@ # append some fields after the HTML contents of the form # set submit_button_class "" + set has_file 0 $root appendFromScript { # append category fields foreach f $form_fields { @@ -1271,6 +1277,9 @@ } elseif {[$f has_instance_variable editor wym]} { set submit_button_class "wymupdate" } + if {[$f has_instance_variable type file]} { + set has_file 1 + } } # insert unreported errors @@ -1292,6 +1301,7 @@ } set url [export_vars -base [$package_id pretty_link [my name]] {{m "edit"} return_url}] $form setAttribute action $url method POST + if {$has_file} {$form setAttribute enctype multipart/form-data} Form add_dom_attribute_value $form class "margin-form" } my set_form_data $form_fields @@ -1322,12 +1332,16 @@ } File instproc download {} { - my instvar text mime_type package_id item_id revision_id + my instvar mime_type package_id $package_id set mime_type $mime_type set use_bg_delivery [expr {![catch {ns_conn contentsentlength}] && [info command ::bgdelivery] ne ""}] $package_id set delivery \ [expr {$use_bg_delivery ? "ad_returnfile_background" : "ns_returnfile"}] + if {[my exists_query_parameter filename]} { + set filename [my query_parameter filename] + ns_set put [ns_conn outputheaders] Content-Disposition "attachment;filename=$filename" + } #my log "--F FILE=[my full_file_name]" return [my full_file_name] }