xowiki::FormPage instproc www-file-upload (public)

 <instance of xowiki::FormPage[i]> www-file-upload

Defined in 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)

Partial Call Graph (max 5 caller/called nodes):
%3 ad_script_abort ad_script_abort (public) security::csrf::validate security::csrf::validate (public) xowiki::FormPage instproc www-file-upload xowiki::FormPage instproc www-file-upload xowiki::FormPage instproc www-file-upload->ad_script_abort xowiki::FormPage instproc www-file-upload->security::csrf::validate

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]
set fileName [:query_parameter name:graph [ns_queryget upload]]

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_abort
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: