On Jan 2, 2008, at 12:00 PM, Xiong, Bob wrote:

> I'm struggling with CGI::Pretty to implement a button to let users  
> download
> files from a web server.

Like John said, a button can be scripted to request a URL when clicked.

<input type="button" value="Click Me" onclick="location.href =  
'http://whatever'">

If you need to dynamically locate or process the file on the server  
side you can do something like this:

(It's PHP code. Sorry. The HTTP part is the good stuff.)

     header("Pragma: public"); // required
     header("Expires: 0");
     header("Cache-Control: must-revalidate, post-check=0, pre- 
check=0");
     header("Cache-Control: private",false); // required for certain  
browsers
     header("Content-Transfer-Encoding: binary");
     header("Content-Type: " . $mimetype);
     header("Content-Length: " . $filesize);
     header("Content-Disposition: attachment; filename=\"" . $name .  
"\";" );

... followed by printing "\n\n" and the contents of the file.
 
_______________________________________________
Boston-pm mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to