A
Alain Star
Hello,
I am trying to write a routine wich, when called from a browser, give the
possibility to download a file.
I have almost succeded but, the only things wich do not work properly is:
- there is no dialog box to choose save / open
- the saved name of the file is wronf (download.cgi.mp3)
Any idea what I am doing wrong? Thanks!
Following, example URL, sub.
http://www.cri.ch/cgi-bin/download.cgi?file=dassault.mp3&send=1
############################################################################
###
sub sendMP3 {
my $file = '/home/sites/site7/data/download/dassault.mp3' ;
open( TUNE, "< $file " ) ;
binmode TUNE ;
my $tunesize = ( stat(TUNE) )[7];
binmode STDOUT ;
print $q->header( -type => 'audio/x-mp3',
-Content_length => $tunesize
);
my $buf; while ( read(TUNE, $buf, 32768) ) { print STDOUT $buf; }
close(TUNE);
exit( 0 );
}
############################################################################
###
I am trying to write a routine wich, when called from a browser, give the
possibility to download a file.
I have almost succeded but, the only things wich do not work properly is:
- there is no dialog box to choose save / open
- the saved name of the file is wronf (download.cgi.mp3)
Any idea what I am doing wrong? Thanks!
Following, example URL, sub.
http://www.cri.ch/cgi-bin/download.cgi?file=dassault.mp3&send=1
############################################################################
###
sub sendMP3 {
my $file = '/home/sites/site7/data/download/dassault.mp3' ;
open( TUNE, "< $file " ) ;
binmode TUNE ;
my $tunesize = ( stat(TUNE) )[7];
binmode STDOUT ;
print $q->header( -type => 'audio/x-mp3',
-Content_length => $tunesize
);
my $buf; while ( read(TUNE, $buf, 32768) ) { print STDOUT $buf; }
close(TUNE);
exit( 0 );
}
############################################################################
###