in reply to Download file to browser
There are quite a lot of things to understand and we can't help unless you tell us which pieces you need help with!use CGI; my $html= new CGI; #get the file name from URL ex. http://<server_IP>/cgi-bin/download.cg +i?a=testing.txt my $file= $html->param('a'); # $file is nothing but testing.txt my $filepath= "/var/www/upload/$file"; print ("Content-Type:application/x-download\n"); print "Content-Disposition: attachment; filename=$file\n\n"; open FILE, "< $filepath" or die "can't open : $!"; binmode FILE; local $/ = \10240; while (<FILE>){ print $_; } close FILE; # use Unlink if u want to delete the files after download. #unlink ($filepath);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Download file to browser
by marto (Cardinal) on Apr 22, 2024 at 12:32 UTC | |
by david.woosley (Initiate) on Apr 22, 2024 at 19:16 UTC | |
by marto (Cardinal) on Apr 22, 2024 at 19:28 UTC | |
|