M
mortgages2005
I need to download a text file from my server. I've tried to use a
program to email it and another to make the browser download the file
with a file save as dialog. The text file has a few charaters and then
some spacing, as many as 120 spaces following by a new line. (line
feed carriage return) I hear unix or linux stores a new line as a line
feed only. After the file is saved to my hard disk through the save
file routine, I should be able to open it up in notepad and not see a
whole bunch of little squares which replaced all the carriage returns.
I need an exact copy of the file as it is correctly saved on the
server. I know it is correct because I'm able to drag it from my FTP
client into my local browser and it opens up in notepad without the
little squares. I can also even right click on the file on my server,
and do view the file, which will transer it over to my computer, open
it in notepad, and there won't be any square boxes replaceing the
carriage returns.
Why is it when I save a file this happens? Is it my browser settings?
I've tried two browsers. They both do the same thing.
Here is the code:
#!/usr/bin/perl
use CGI ':standard';
use CGI::Carp qw(fatalsToBrowser);
my $files_location;
my $ID;
my @fileholder;
my $subdirectory=param('subdirectory');
$ID = param('ID') . "du.txt";
$files_location = "/home/mortga20/public_html/$subdirectory/";
#print "Content-type: text/html\n\n";
#print "files_location is " . $files_location;
#exit;
if ($ID eq '') {
print "Content-type: text/html\n\n";
print "You must specify a file to download.";
exit;
}
open(DLFILE, "<$files_location/$ID") || Error('open',
'$files_location/$ID');
print header( -type => 'application/x-download',
-attachment => $ID,
);
print $_ while (read(DLFILE, $_, 1024));
close (DLFILE) || die ("Can't close file!");
open(LOG, ">>/home/mortga20/public_html/$subdirectory/log.txt") || die
("Can't open file!");
print LOG "$ID\n";
close (LOG);
print "Content-Type:application/x-download\n";
print "Content-Disposition:attachment;filename=$ID\n\n";
print @fileholder
program to email it and another to make the browser download the file
with a file save as dialog. The text file has a few charaters and then
some spacing, as many as 120 spaces following by a new line. (line
feed carriage return) I hear unix or linux stores a new line as a line
feed only. After the file is saved to my hard disk through the save
file routine, I should be able to open it up in notepad and not see a
whole bunch of little squares which replaced all the carriage returns.
I need an exact copy of the file as it is correctly saved on the
server. I know it is correct because I'm able to drag it from my FTP
client into my local browser and it opens up in notepad without the
little squares. I can also even right click on the file on my server,
and do view the file, which will transer it over to my computer, open
it in notepad, and there won't be any square boxes replaceing the
carriage returns.
Why is it when I save a file this happens? Is it my browser settings?
I've tried two browsers. They both do the same thing.
Here is the code:
#!/usr/bin/perl
use CGI ':standard';
use CGI::Carp qw(fatalsToBrowser);
my $files_location;
my $ID;
my @fileholder;
my $subdirectory=param('subdirectory');
$ID = param('ID') . "du.txt";
$files_location = "/home/mortga20/public_html/$subdirectory/";
#print "Content-type: text/html\n\n";
#print "files_location is " . $files_location;
#exit;
if ($ID eq '') {
print "Content-type: text/html\n\n";
print "You must specify a file to download.";
exit;
}
open(DLFILE, "<$files_location/$ID") || Error('open',
'$files_location/$ID');
print header( -type => 'application/x-download',
-attachment => $ID,
);
print $_ while (read(DLFILE, $_, 1024));
close (DLFILE) || die ("Can't close file!");
open(LOG, ">>/home/mortga20/public_html/$subdirectory/log.txt") || die
("Can't open file!");
print LOG "$ID\n";
close (LOG);
print "Content-Type:application/x-download\n";
print "Content-Disposition:attachment;filename=$ID\n\n";
print @fileholder