Hi all,
Thanks for sharing your knowledge in the past,
I want to allow user to download a file on the webserver to their local system using Just a browser.
the file readme.txt is stored in /tmp folder.
please tell me how can i implement it.
Thanks yall,
Rakesh
|
Go4Expert Founder
|
![]() |
| 20Sep2006,10:37 | #2 |
|
Just putting that in the web server directory will allow it to download or you can use any server side script even to achieve the same. in PHP it would be something like
Code: PHP
|
|
Go4Expert Member
|
|
| 22Sep2006,22:47 | #3 |
|
Thanks shabbir,
but I have a a link like: <a href=http://xyz.com/FileName="abc.zip"> abc.zip</a> and when the user clicks on abc.zip hyper link, the FileName is passed to download script, which triggers the automatic download process(save as popup). I dont know how to do this. have any idea? Thanks |
|
Go4Expert Member
|
|
| 23Sep2006,00:56 | #4 |
|
This is what I have and am trying to do.
the file name is passed to this script as a query string Code:
if (length ($ENV{'QUERY_STRING'}) > 0){
$buffer = $ENV{'QUERY_STRING'};
@pairs = split(/&/, $buffer);
foreach $pair (@pairs){
($name, $value) = split(/=/, $pair);
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$in{$name} = $value;
}
}
$filename=$in{'FileName'};
my $files_location;
$files_location = "/tmp";
if ($filename eq '') {
print "You must specify a file to download.";
} else {
my $data="";
open(DLFILE, "<$files_location/$filename") || Error('open', 'file');
while(<DLFILE>) { $data .= $_; }
close(DLFILE) || Error ('close', 'file');
print "Content-Type: application/x-unknown\r\n";
print "Content-Disposition: attachment;$filename\r\n";
print "Content-length: ", length($data), "\r\n\r\n$data";
}
What i am trying to do is to let user save the file where ever they want with the Save As pop-up Please help, Rakesh |

