I have a Perl CGI script which invokes HTML form, takes input, and process it.
I want to upload the resultant file to the same localhost server (apache2) but after processing, it generates the resultant file and stops without displaying anything. The resultant file is in a temporary folder ($dir) located in cgi-bin folder.
I tried using the <a href>
HTML tag but it is not working.
print "Content-Type: text/html";
print '<a href="http://localhost/cgi-bin/$dir/test.txt" target="_top">Download your file</a>';
Is there any other way to use <a href>
tag in Perl?
The resultant file is in a temporary folder ($dir) located in cgi-bin folder
Don't do that.
cgi-bin
should contain only CGI programs.
Your server is almost certainly configured so it will try to execute anything there as a CGI program.
Your text file, which contains data, is not a program, and trying to treat it as one will cause errors.
Save the file somewhere outside cgi-bin (or don't save it at all and just output it from the CGI program directly to the browser).