gnznroses
07-13-2005, 12:47 AM
i'm trying to update a CGI file -- a download counter -- so that instead of always redirecting the user to the file automatically (after incrementing the download count) that i can optionally specify that it show an html file that says "click here to start download". cause with sp2 you can't open a new window to this cgi and it redirect, the window just instantly closes. here's what i've got:
first the script does some usual stuff to read the queery string and put the paramaters into variables, which works fine, then i've got this:
if ( $auto ne 0 ){
print "Location: $url\n\n";
}
else{
print "Content-type: text/html\n\n";
print "<html><head><title>Download</title>\n<style type=\"text/css\">\n<!--\nA { text-decoration:none; font-size:8pt; font-family:verdana\n-->\n</style>\n</head>\n<body bgcolor=#dcd5ca text=#685B48 link=#685B48 vlink=#685B48 alink=#685B48 style=\"font-family:verdana\">\n";
print "<center><br>\n<a href=\"$url\">Click here to start download</a>\n</center></body></html>\n";
}
it works fine when i specify auto=0, but now for some reason when it auto-redirects it shows the file as text in the browser. and all code above this has not been modified from the original. someone suggested i set the content type to application/octet-stream before redirecting, but then the browser simply prints out "Location: " thne the url.
can anyone help?
first the script does some usual stuff to read the queery string and put the paramaters into variables, which works fine, then i've got this:
if ( $auto ne 0 ){
print "Location: $url\n\n";
}
else{
print "Content-type: text/html\n\n";
print "<html><head><title>Download</title>\n<style type=\"text/css\">\n<!--\nA { text-decoration:none; font-size:8pt; font-family:verdana\n-->\n</style>\n</head>\n<body bgcolor=#dcd5ca text=#685B48 link=#685B48 vlink=#685B48 alink=#685B48 style=\"font-family:verdana\">\n";
print "<center><br>\n<a href=\"$url\">Click here to start download</a>\n</center></body></html>\n";
}
it works fine when i specify auto=0, but now for some reason when it auto-redirects it shows the file as text in the browser. and all code above this has not been modified from the original. someone suggested i set the content type to application/octet-stream before redirecting, but then the browser simply prints out "Location: " thne the url.
can anyone help?