I have a script "licence.cg i" write in python which generate text files and I would like that the user click on a button and he can download this file.
_1er solution:_
I found in my research that I have to add the Content-Disposition... So I created an other script call /download.cgi /and I obtain a popup "save as" but how the script "licence.cg i" can give the variable filename to the script download.cgi?
-----------------------------------------------------------*_
licence.cgi
_*print "Content-type: text/html"
print
...
filename="/var/www/licence/licence-20070511-152214"
...
print '<form name="input" action=%s method="POST">< INPUT TYPE="SUBMIT" VALUE="VIEW the file"></form>' %filename
print '<form method="POST" action="/cgi-bin/downloadfile.cg i"> <INPUT TYPE="SUBMIT" VALUE="DOWNLOAD the file"></form>'
...
-----------------------------------------------------------
download.cgi
#!/usr/bin/python
import string, sys
import cgi
import cgitb; cgitb.enable()
print "Content-Disposition: attachment; filename= %s " %filename
print "Content-Type: application/text"
print
try:
fp=open(licence file, "r")
content = fp.read()
print content
except:
print "Couldn't find the file."
-----------------------------------------------------------
_
2 solution:_
I would like to have only one script, only "licence.cg i". How can I do ?
Thanks you very much for your help
--
Laetitia
_1er solution:_
I found in my research that I have to add the Content-Disposition... So I created an other script call /download.cgi /and I obtain a popup "save as" but how the script "licence.cg i" can give the variable filename to the script download.cgi?
-----------------------------------------------------------*_
licence.cgi
_*print "Content-type: text/html"
...
filename="/var/www/licence/licence-20070511-152214"
...
print '<form name="input" action=%s method="POST">< INPUT TYPE="SUBMIT" VALUE="VIEW the file"></form>' %filename
print '<form method="POST" action="/cgi-bin/downloadfile.cg i"> <INPUT TYPE="SUBMIT" VALUE="DOWNLOAD the file"></form>'
...
-----------------------------------------------------------
download.cgi
#!/usr/bin/python
import string, sys
import cgi
import cgitb; cgitb.enable()
print "Content-Disposition: attachment; filename= %s " %filename
print "Content-Type: application/text"
try:
fp=open(licence file, "r")
content = fp.read()
print content
except:
print "Couldn't find the file."
-----------------------------------------------------------
_
2 solution:_
I would like to have only one script, only "licence.cg i". How can I do ?
Thanks you very much for your help
--
Laetitia