Question

I'm a newbie working on OpenACS architecture and need to upload a .xml file through TCL. I went through the documentation and tried to work around with the code mentioned here: http://wiki.tcl.tk/13675

However, I'm unable to understand the code and the copy-paste won't work. Could someone please suggest a easier working way to upload a file in TCL? A working code would be of great help.

I need to upload a file through a HTTP form(with input type file parameter) and I'm asking for server-side code.

No correct solution

OTHER TIPS

OpenACS already has file uploading built in (assuming you're using the OpenACS form builder aka ad_form, template::form - it has many names!). The specific widget you need to use is template::widget::file

A worked example is in the General Comments package (see file-ae.adp, file-add.tcl and file-add-2.tcl): http://cvs.openacs.org/browse/OpenACS/openacs-4/packages/general-comments/www/file-ae.adp?r=1.6 http://cvs.openacs.org/browse/OpenACS/openacs-4/packages/general-comments/www/file-add.tcl?r=1.4 http://cvs.openacs.org/browse/OpenACS/openacs-4/packages/general-comments/www/file-add-2.tcl?r=1.6

Specifically, look out for the 2 ad_page_contract parameters, and follow those variables down through the code:

upload_file:notnull
upload_file.tmpfile:tmpfile

Re-inventing network protocols is not so much worth in most cases, so I'd like to recommend using proven community libs. From my personal experience, I'm pretty glad to deal with libcurl (see http://curl.haxx.se/libcurl/tcl)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top