use CGI; my $html= new CGI; #get the file name from URL ex. http:///cgi-bin/download.cgi?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 (){ print $_; } close FILE; # use Unlink if u want to delete the files after download. #unlink ($filepath);