xowiki::FormPage instproc www-file-upload (public)
<instance of xowiki::FormPage> www-file-upload
Defined in /var/www/openacs.org/packages/xowiki/tcl/xowiki-www-procs.tcl
This web-callable method can be used for uploading files using the current object as parent object for the new content. This method is typically called via drop-zone in a POST request, where the FormPage is a folder (which is treated as parent object)
- Testcases:
- No testcase defined.
Source code: if {[ns_conn method] ne "POST"} { error "method should be called via POST" } # # Get the disposition via query parameter. We have currently the # following disposition classes defined (see # xowiki-uploader-procs.tcl) # # - ::xowiki::UploadFile # - ::xowiki::UploadPhotoForm # - ::xowiki::UploadFileIconified # ::security::csrf::validate set disposition [:query_parameter disposition:wordchar File] # # Filename is sanitized. If the filename contains only invalid # characters, "ad_sanitize_filename" might return empty, and we # complain. # set fileName [ad_sanitize_filename [ns_queryget name [ns_queryget upload]]] if {[string length $fileName] == 0} { ad_return_complaint 1 [_ acs-templating.Invalid_filename] ad_script_abort } set dispositionClass ::xowiki::UploadFile if {[info commands ::xowiki::Upload$disposition] ne ""} { set dispositionClass ::xowiki::Upload$disposition } #ns_log notice "disposition class '$dispositionClass'" set dispositionObject [$dispositionClass new -file_name $fileName -content_type [ns_queryget upload.content-type] -tmpfile [ns_queryget upload.tmpfile] -parent_object [self]] set result [$dispositionObject store_file] $dispositionObject destroy ns_return [dict get $result status_code] text/plain [dict get $result message] ad_script_abortXQL Not present: Generic, PostgreSQL, Oracle