• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 208
  • Last Modified:

Change default filename when downloading from cgi


I am using a cgi script (perl with windows nt) to send file to client browser (download fonction).

The problem is : when the window open (save as), the default name of the file is the name of the cgi program.

how can i change the default name before the "save as" window open ??

I use this code to send the file :

 print "HTTP/1.0 302 Found\n";
 print "Content-type: multipart/x-zip\n\n";
 binmode STDOUT;
 open (FILE, $file);
 read (FILE, $buffer, -s $file);
 print $buffer;


  • 2
1 Solution
Michel PlungjanIT ExpertCommented:
1. Use the path info method:
so myplprogram is the executable and /myparms.zip will be accessible to your program in the path-info environment variable.
This works for most browsers...

2. Use the HTTP header
Content-disposition: inline; filename=myfile.zip

No special chars allowed in the filename...

Michel PlungjanIT ExpertCommented:
PS: the filename may have to be in quotes:
Content-disposition: inline; filename="myfile.zip"

and you might want to use this too:
Content-type: multipart/x-zip; name="myfile.zip"

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now