From: Sailer H. (ext.) <Hol...@ks...> - 2001-01-19 13:22:05
|
Hello, I'm trying to post files to the server in two ways: 1. via cgi: posting an file fails due to: in cgi.tcl: proc CgiSpawn: fcopy $sock $fd -command [list CgiCopyDone $sock $fd] -size $data(count) -> dependent on size of posted file, CgiCopyDone never got called. cgifile.tml: <form ENCtype="multipart/form-data" action="/cgi-bin/testupload.cgi" method="post"> --------------------------------- File <input type="file" name="the_file" accept="application/*"> <p> <input type=submit> </form> cgi-bin/testupload.tcl: puts "Content-Type: text/html" puts <pre> fconfigure stdin -translation binary puts [read stdin $env(CONTENT_LENGTH)] puts </pre> ------------------------------------------------------------- 2. post file by not calling cgi-process: -> works with all ascii-files as well as binary files < ~ 80 KB. fails with bigger binary files. e.g. compressed tar - archives can't be extracted any more. myfile.tml: --------------- <form ENCtype="multipart/form-data" action="mytestupload.tml" method="post"> ------------------------- File <input type="file" name="the_file" accept="application/*"> <p> <input type=submit> </form> mytestupload.tml: ------------------------- <table border=1 cellpadding=2> [ set html "" set fname "unknown.upload" foreach {n v} [ncgi::nvlist] { switch -- $n { the_file { foreach { vn vv } [lindex $v 0] { append html "<pre> NAME=$vn VALUE=$vv \n</pre>" switch -- $vn { filename { regsub -all {\\} $vv {/} new set fname [ file tail $new ] } } } set fd [ open [ file join / tmp $fname] w] fconfigure $fd -translation binary puts -nonewline $fd [ncgi::value the_file] close $fd append html [html::h1 "File saved on [ file join / tmp $fname]"] } } append html [html::row $n [html::tableFromList [lindex $v 0]]] } set html ] </table> I'm using tclhttpd3.2.1 and tcl8.3 / tcl8.3.2 and tcllib0.8 (no threads). I've tested on Win NT and QNX Is there a bug or am i doing something wrong? Thanks in advance, Holger Sailer |