From: Brent W. <bre...@in...> - 2001-01-27 01:33:53
|
>>>"Anders Nilsson" said: > Hi. > > I'm trying to implement a file uploadpage with cgi. I've taken > a look at the demo that comes with the tclhttpd, especially the > testupload.tml file. For me, since I don't really get the .tml > workings, the main part of recieving the uploaded file is this: > > foreach {n v} [ncgi::nvlist] { > append html [html::row $n [html::tableFromList [lindex $v 0]]] > append html [html::row $n [ncgi::value $n]] > append html <tr>[html::cell "colspan=2" "<pre>[html::quoteFormValue > [lindex $v 1]]</pre>"]</tr> > } > > which nicely breaks down to: > > foreach {n v} [ncgi::nvlist] { > append html "name: $n " > append html "value: $v " > } > > for the sake of clarity. Now, that works just fine, but when I > try to put that into my own ncgitest.cgi file, it doesn't work > as in the .tml file above. When I run my own cgi-script, I don't > get any values in the $n variable, and in the $v variable I get > the whole thing. The differences below seem to indicate that the CGI case isn't correctly detecting the multipart/ content type. The ncgi:: package does some extra work for you in this case to unbundle the arguments as you can see. You should print out the $env(CONTENT_TYPE) in your CGI - perhaps TclHttpd isn't passing through the right thing. > Ie. the .tml file gives these values: > $n: hide_me > $v: {content-disposition form-data name hide_me} {hello, world} > > while my cgi-file gives these values: > $n: <empty> > $v: {} {Content-Disposition: form-data; name="hide_me" hello, world } > > Also, when I try to upload a little bigger imagefile the .tml version > handles it nicely, but my cgi-file just hangs... This bug was recently diagnosed. You can either backtrack to 3.2 from 3.2.1, or use the attached cgi.tcl and doc.tcl files. The fix is only in cgi.tcl, but it uses a new API provided by doc.tcl for other reasons. I'll put out a 3.2.2 "soon", but I can't say just when I'll get to it. Actually, but real bug is in Tcl's fcopy command - the 3.2.1 version of cgi.tcl switched to using fcopy in a certain case that exposed the fcopy bug. That bug has also been diagnosed. Thanks to Don Porter for all that sleuthing! These files are up-to-date in CVS. -- Brent Welch <bre...@in...> http://www.interwoven.com |