By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,934 Members | 1,685 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,934 IT Pros & Developers. It's quick & easy.

How to download big file

P: 7
I need to download a 200MB file from server. I wrote a server side porgram in perl like this
Expand|Select|Wrap|Line Numbers
  1. $ID = $xmlPath."PSIRT_EOX_OFFLINE.txt";
  2.  
  3.  
  4.       if ($ID eq '') {  
  5.       print "Content-type: text/html\n\n";  
  6.       print "You must specify a file to download.";  
  7.       } else {
  8.       print "Content-Type:application/x-download\n"; 
  9.       print "Content-Disposition:attachment;filename=PSIRT_EOX_OFFLINE.txt\n\n";
  10.       open(DLFILE, "$ID") || Error();
  11.         @fileholder = <DLFILE>;
  12.  
  13.       #binmode(DLFILE);
  14.  
  15.       close (DLFILE) || Error ('close', 'file');
  16.  
  17.       print "Content-Type:application/x-download\n"; 
  18.       print "Content-Length: $size\n";
  19.        print "Content-Disposition:attachment;filename=PSIRT_EOX_OFFLINE.txt\n\n";
  20.         print @fileholder ;
When I execute the perl script through browser, it takes around two mins time to popup the file download dialog. How can the time be reduced? Any help?
May 20 '08 #1
Share this Question
Share on Google+
5 Replies


KevinADC
Expert 2.5K+
P: 4,059
I need to download a 200MB file from server. I wrote a server side porgram in perl like this
$ID = $xmlPath."PSIRT_EOX_OFFLINE.txt";


if ($ID eq '') {
print "Content-type: text/html\n\n";
print "You must specify a file to download.";
} else {
print "Content-Type:application/x-download\n";
print "Content-Disposition:attachment;filename=PSIRT_EOX_OFFLINE. txt\n\n";
open(DLFILE, "$ID") || Error();
@fileholder = <DLFILE>;

#binmode(DLFILE);

close (DLFILE) || Error ('close', 'file');

print "Content-Type:application/x-download\n";
print "Content-Length: $size\n";
print "Content-Disposition:attachment;filename=PSIRT_EOX_OFFLINE. txt\n\n";
print @fileholder ;

When I execute the perl script through browser, it takes around two mins time to popup the file download dialog. How can the time be reduced? Any help?

Why have you printed the download header twice? I don't know if that is creating a problem but is certainly is not necessary. Ty like this and see if it helps:

Expand|Select|Wrap|Line Numbers
  1. if ($ID eq '') {  
  2.    print "Content-type: text/html\n\n";  
  3.    print "You must specify a file to download."; 
  4.    exit; 
  5. }
  6. else {
  7.    $size = -s $ID; 
  8.    open(DLFILE, $ID) or Error();
  9.    print "Content-Type:application/x-download\n"; 
  10.    print "Content-Length: $size\n";
  11.    print "Content-Disposition:attachment;filename=PSIRT_EOX_OFFLINE.txt\n\n";
  12.    print <DLFILE>;
  13.    close (DLFILE) or Error ('close', 'file');
  14. }
  15.  
May 20 '08 #2

P: 7
Why have you printed the download header twice? I don't know if that is creating a problem but is certainly is not necessary. Ty like this and see if it helps:

Expand|Select|Wrap|Line Numbers
  1. if ($ID eq '') {  
  2.    print "Content-type: text/html\n\n";  
  3.    print "You must specify a file to download."; 
  4.    exit; 
  5. }
  6. else {
  7.    $size = -s $ID; 
  8.    open(DLFILE, $ID) or Error();
  9.    print "Content-Type:application/x-download\n"; 
  10.    print "Content-Length: $size\n";
  11.    print "Content-Disposition:attachment;filename=PSIRT_EOX_OFFLINE.txt\n\n";
  12.    print <DLFILE>;
  13.    close (DLFILE) or Error ('close', 'file');
  14. }
  15.  
I tried with this code but didn't get any solution.
May 21 '08 #3

KevinADC
Expert 2.5K+
P: 4,059
tyr with a small file and see if the dialog box appears sooner. I am not sure if the size of the file has anything to do with the delay.
May 21 '08 #4

P: 7
tyr with a small file and see if the dialog box appears sooner. I am not sure if the size of the file has anything to do with the delay.
Yes. I tried with a small file. It appears immediatly. But I want to do it with a big file. Isn't there any way to do it?
May 22 '08 #5

KevinADC
Expert 2.5K+
P: 4,059
I don't know, I don't think this has anything to do with perl, more of a server issue.
May 22 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.