I have one doubt that if we click a link then a prompt should come as Open file (or) Save file and if we click Save file the file should be downloaded into the default path of the current system.
in perl i written the code as below:
Expand|Select|Wrap|Line Numbers
- use Text::CSV;
- use Apache::Request;
- use Apache::File;
- sub handler
- {
- my $r = Apache::Request->new(shift);
- my $download = $r->param('download');
- if($download eq '' )
- {
- print <<HTML;
- <html>
- <head>
- <script type='text/javascript'>
- function transfer(frm)
- {
- var url = 'http://10.202.1.22/practice/newldap?download=yes';
- document.frm.action = url;
- document.frm.submit();
- }
- </script>
- # In this area a csv file is created
- <a href='javascript:transfer(this.form)' class='Download'>File in CSV Format</a>
- </form>
- </center>
- </body>
- </html>
- HTML
- }
- elsif($download eq 'yes')
- {
- # To make the browser for downloading the file
- $r->send_http_header('application/vnd.ms-excel');
- open FH, "</tmp/$date.csv";
- my $le = $r->send_fd(FH);
- }
- return OK;
- }
- 1;
It is very urgent friends, please help me.