[Don Libes] cgi.tcl package is great for rapid development of dynamic web sites. http://expect.nist.gov/cgi.tcl/ See also the [cgi.tcl extension] page, which has more information on this very useful tool. ---- '''An Upload Example''' [WJR] Here's an example script that could be used to upload files. If anything it demonstrates how easy [cgi.tcl] makes such as interface. There are no security mechanisms in this script, so make sure to control for unauthorized uploads! This particular example is from a Windows/Apache setup but I'm sure only minimal changes would be required for other platforms. #!d:/tcl/bin/tclsh.exe package require cgi # Upload dir set updir [file join {d:\Apache2\htdocs\my-app\uploads\in}] cgi_eval { # Read all CGI input and decode it cgi_input # Name of file on server, "the_file" represents the form field # used to upload the file set server [cgi_import_file -server the_file] # If file size is 0, delete the CGI temp file and redirect # client to the upload error page if {[file size $server] == 0} { file delete $server cgi_redirect /my-app/upload-error.html exit } # Filename sent by the client (tail only, IE sends the entire # path of the client file) set client [file tail [cgi_import_file -client the_file]] # Make sure the uploaded file has an acceptable filename regsub -all {([^\w.-])} $client - safe_file regsub {^[-.]+} $safe_file "" safe_file # Move (and rename) the file to the uploads/in directory # Existing files will be overwritten file rename -force $server $updir/$safe_file # Redirect client cgi_redirect /my-app/upload.html } ---- [Category Internet]