summaryrefslogtreecommitdiff
path: root/web/src/cgi.tcl-1.10/example/download.cgi
blob: c82cb3f57629ebb3854ef75f753a4dcb1296fbb4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/depot/path/tclsh

package require cgi

set msg "Very funny, Scotty.  Now beam down my clothes."
set filename "scotty.msg"

cgi_eval {
    source example.tcl

    cgi_input

    if {[catch {cgi_import style}]} {
	cgi_title "download example"
	body {
	    cgi_suffix ""
	    form download.cgi/$filename {
		puts "This example demonstrates how to force files to be
		downloaded into a separate file via the popup file browser."
		br
		puts "Download data"
		submit_button "style=in window"
		submit_button "style=in file using popup file browser"
	    }
	}
    } else {
	if {[regexp "in window" $style]} {
	    title "Display data in browser window"
	} else {
	    cgi_http_head {
		content_type application/x-download
	    }
	}
	puts $msg
    }
}