1

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.

Roalt
  • 8,330
  • 7
  • 41
  • 53
  • 1
    What do you mean with upload? FTP, a HTTP form, SCP? – Johannes Kuhn May 16 '13 at 09:23
  • 2
    Are you writing client code or server code? Are you trying to write a message to do the upload, or to handle an upload coming from a browser? What exactly is the problem that you are having? “Unable to get the code working” isn't a precise issue we can address… – Donal Fellows May 16 '13 at 10:59
  • I need to upload a file through a HTTP form(with input type file parameter) and I'm asking for server-side code. For Client-side code, I believe writing plain html in .adp page would suffice. – Rachit Goel May 17 '13 at 06:41
  • @DonalFellows I've no great idea of TCL so these codes are beyond my understanding. I need a simple working code to upload a file through a browser which would work on aolserver. – Rachit Goel May 17 '13 at 06:57

2 Answers2

0

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
TrojanName
  • 4,853
  • 5
  • 29
  • 41
  • @Rachit, I've added more links to the working examples. If you have any questions on how it all fits together, I'd be happy to explain. – TrojanName May 17 '13 at 10:44
-1

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)

Yury Schkatula
  • 5,291
  • 2
  • 18
  • 42
  • Hi Yury, can you give me the simplest code possible through this library to upload a file? – Rachit Goel May 17 '13 at 06:48
  • This would be for the client side, but from your update it seems you are concerned with the server side, so this answer is not relevant there. – Colin Macleod May 17 '13 at 07:12